|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.marc4j.MarcXmlReader
public class MarcXmlReader
An iterator over a collection of MARC records in MARCXML format.
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 Summary | |
---|---|
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. |
Method Summary | |
---|---|
boolean |
hasNext()
Returns true if the iteration has more records, false otherwise. |
Record |
next()
Returns the next record in the iteration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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 handlerMethod Detail |
---|
public boolean hasNext()
hasNext
in interface MarcReader
public Record next()
next
in interface MarcReader
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |