Package org.marc4j

Examples of org.marc4j.MarcReader


            // create the input stream
            InputStream input = ReadMarcExample.class
                    .getResourceAsStream("resources/summerland.mrc");

            // parse the input
            MarcReader reader = new MarcStreamReader(input);
            MarcWriter writer = new MarcXmlWriter(result);
            while (reader.hasNext()) {
                Record record = reader.next();
                writer.write(record);
            }
            writer.close();
           
            out.close();
View Full Code Here


    public static void main(String args[]) throws Exception {

        InputStream input = ReadMarcExample.class
                .getResourceAsStream("resources/summerland.mrc");
        MarcReader reader = new MarcStreamReader(input);

        // OutputFormat format = new OutputFormat("xml", "UTF-8", true);

        // XMLSerializer serializer = new XMLSerializer(System.out, format);
        // Result result = new SAXResult(serializer.asContentHandler());

        // MarcXmlWriter writer = new MarcXmlWriter(result);
        // writer.setConverter(new AnselToUnicode());
        while (reader.hasNext()) {
            Record record = reader.next();
            // writer.write(record);
        }
        // writer.close();

    }
View Full Code Here

    public static void main(String args[]) throws Exception {

        URL url = new URL(
                "http://www.loc.gov/standards/marcxml/Sandburg/sandburg.mrc");

        MarcReader reader = new MarcStreamReader(url.openStream());
        while (reader.hasNext()) {
            Record record = reader.next();
            System.out.println(record.toString());
        }

    }
View Full Code Here

    public static void main(String args[]) throws Exception {

        InputStream input = ReadMarcExample.class
                .getResourceAsStream("resources/chabon.mrc");

        MarcReader reader = new MarcStreamReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();
           
            // get control field with tag 008
            ControlField controlField = (ControlField) record
                    .getVariableField("008");
           
View Full Code Here

        InputStream input = HandleExceptionExample.class
                .getResourceAsStream("resources/error.mrc");

        try {
            MarcReader reader = new MarcStreamReader(input);
            while (reader.hasNext()) {
                Record record = reader.next();
                System.out.println(record.toString());
            }
        } catch (MarcException e) {
            System.out.println("something went wrong man!");
View Full Code Here

    public static void main(String args[]) throws Exception {

        InputStream input = ModsToMarc21lExample.class
                .getResourceAsStream("resources/modsoutput.xml");

        MarcReader reader = new MarcXmlReader(input,
                "http://www.loc.gov/standards/marcxml/xslt/MODS2MARC21slim.xsl");

        while (reader.hasNext()) {
            Record record = reader.next();
            System.out.println(record.toString());

        }
    }
View Full Code Here

        InputStream input = AddLocationExample.class
                .getResourceAsStream("resources/summerland.mrc");

        MarcFactory factory = MarcFactory.newInstance();

        MarcReader reader = new MarcStreamReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();

            DataField field = factory.newDataField("856", '4', '2');
            field.addSubfield(factory.newSubfield('3',
                "Contributor biographical information"));
            field.addSubfield(factory.newSubfield('u',
View Full Code Here

    public static void main(String args[]) throws Exception {

        InputStream input = ReadMarcExample.class
                .getResourceAsStream("resources/summerland.mrc");

        MarcReader reader = new MarcStreamReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();
            System.out.println(record.toString());
        }

    }
View Full Code Here

    public static void main(String args[]) throws Exception {

        InputStream input = ReadMarcExample.class
                .getResourceAsStream("resources/summerland.mrc");

        MarcReader reader = new MarcStreamReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();

            // check if the cataloging agency is DLC
            List result = record.find("040", "DLC");
            if (result.size() > 0)
                System.out.println("Agency for this record is DLC");
View Full Code Here

    public static void main(String args[]) throws Exception {

        InputStream input = ReadMarcExample.class
                .getResourceAsStream("resources/summerland.mrc");

        MarcReader reader = new MarcStreamReader(input);

        DOMResult result = new DOMResult();
        MarcXmlWriter writer = new MarcXmlWriter(result);
        writer.setConverter(new AnselToUnicode());
        while (reader.hasNext()) {
            Record record = (Record) reader.next();
            writer.write(record);
        }
        writer.close();

        Document doc = (Document) result.getNode();
View Full Code Here

TOP

Related Classes of org.marc4j.MarcReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.