public class MarcXmlReader extends Object implements MarcReader
Basic usage:
InputStream input = new FileInputStream("file.xml");
MarcReader reader = new MarcXmlReader(input);
while (reader.hasNext()) {
Record record = reader.next();
// Process record
}
Check the org.marc4j.marc package for examples about the use of the Record
object model.
You can also pre-process the source to create MARC XML from a different format using an XSLT stylesheet. The following example creates an iterator over a collection of MARC records in MARC XML format from a MODS source and outputs MARC records in MARC21 format:
InputStream in = new FileInputStream("modsfile.xml");
MarcStreamWriter writer = new MarcStreamWriter(System.out, Constants.MARC8);
MarcXmlReader reader =
new MarcXmlReader(in, "http://www.loc.gov/standards/marcxml/xslt/MODS2MARC21slim.xsl");
while (reader.hasNext()) {
Record record = reader.next();
writer.write(record);
}
writer.close();
| Constructor and Description |
|---|
MarcXmlReader(InputSource input)
Constructs an instance with the specified input source.
|
MarcXmlReader(InputSource input,
Source stylesheet)
Constructs an instance with the specified input source and stylesheet source.
|
MarcXmlReader(InputSource input,
TransformerHandler th)
Constructs an instance with the specified input source and transformer handler.
|
MarcXmlReader(InputStream input)
Constructs an instance with the specified input stream.
|
MarcXmlReader(InputStream input,
Source stylesheet)
Constructs an instance with the specified input stream and stylesheet source.
|
MarcXmlReader(InputStream input,
String stylesheetUrl)
Constructs an instance with the specified input stream and stylesheet location.
|
MarcXmlReader(InputStream input,
TransformerHandler th)
Constructs an instance with the specified input stream and transformer handler.
|
public MarcXmlReader(InputStream input)
input - the input streampublic MarcXmlReader(InputSource input)
input - the input sourcepublic MarcXmlReader(InputStream input, String stylesheetUrl)
Record objects.input - the input streamstylesheetUrl - the stylesheet locationpublic MarcXmlReader(InputStream input, Source stylesheet)
Record
objects.input - the input streamstylesheet - the stylesheet sourcepublic MarcXmlReader(InputSource input, Source stylesheet)
Record
objects.input - the input sourcestylesheet - the stylesheet sourcepublic MarcXmlReader(InputStream input, TransformerHandler th)
TransformerHandler is used to transform the source file and should produce
valid MARCXML records. The result is then used to create Record objects. A
TransformerHandler can be obtained from a SAXTransformerFactory with either a
Source or Templates object.input - the input streamth - the transformation content handlerpublic MarcXmlReader(InputSource input, TransformerHandler th)
TransformerHandler is used to transform the source file and should produce
valid MARCXML records. The result is then used to create Record objects. A
TransformerHandler can be obtained from a SAXTransformerFactory with either a
Source or Templates object.input - the input sourceth - the transformation content handlerpublic boolean hasNext()
hasNext in interface MarcReaderpublic Record next()
next in interface MarcReaderCopyright © 2014 FreeLibrary. All Rights Reserved.