Package org.marc4j

Examples of org.marc4j.MarcStreamReader


    public void testMarcXmlWriter() throws Exception {
        InputStream input = getClass().getResourceAsStream(
                "resources/summerland.mrc");
        MarcXmlWriter writer = new MarcXmlWriter(System.out, true);
        MarcStreamReader reader = new MarcStreamReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();
            writer.write(record);
        }
        input.close();
        writer.close();
    }
View Full Code Here


        }
        input.close();
        writer.close();

        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        MarcStreamReader marcReader = new MarcStreamReader(in);
        MarcStreamWriter marcWriter = new MarcStreamWriter(System.out);
        while (marcReader.hasNext()) {
            Record record = marcReader.next();
            marcWriter.write(record);
        }
        in.close();
        marcWriter.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);
        MarcWriter writer = new MarcXmlWriter(System.out, true);

        AnselToUnicode converter = new AnselToUnicode();
        writer.setConverter(converter);

        while (reader.hasNext()) {
            Record record = reader.next();
            writer.write(record);
        }
        writer.close();
    }
View Full Code Here

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

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

        MarcReader reader = new MarcStreamReader(input);
        MarcWriter writer = new MarcStreamWriter(System.out, "UTF8");

        AnselToUnicode converter = new AnselToUnicode();
        writer.setConverter(converter);

        while (reader.hasNext()) {
            Record record = reader.next();
            writer.write(record);
        }
        writer.close();
    }
View Full Code Here

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

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

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

            // get data field 245
            DataField dataField = (DataField) record.getVariableField("245");

            // get indicator as int value
View Full Code Here

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

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

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

            // get the first field occurence for a given tag
            DataField dataField = (DataField) record.getVariableField("245");
            System.out.println(dataField.toString() + '\n');
View Full Code Here

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

        InputStream input = RemoveLocalFieldsExample.class
                .getResourceAsStream("resources/chabon-loc.mrc");

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

            Pattern pattern = Pattern.compile("9\\d\\d");

            List fields = record.getDataFields();
View Full Code Here

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

        OutputStream out = new FileOutputStream("c:/temp/summerland.xml");

        MarcReader reader = new MarcStreamReader(input);
        MarcWriter writer = new MarcXmlWriter(out, true);

        AnselToUnicode converter = new AnselToUnicode();
        writer.setConverter(converter);

        while (reader.hasNext()) {
            Record record = reader.next();
            writer.write(record);
        }
        writer.close();
    }
View Full Code Here

        Hashtable table = new Hashtable();

        int counter = 0;

        MarcReader reader = new MarcStreamReader(input);
        while (reader.hasNext()) {
            counter++;

            Record record = reader.next();

            List fields = record.getVariableFields();
            Iterator i = fields.iterator();
            while (i.hasNext()) {
                VariableField field = (VariableField) i.next();
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);

        String stylesheetUrl = "http://www.loc.gov/standards/mods/v3/MARC21slim2MODS3.xsl";
        Source stylesheet = new StreamSource(stylesheetUrl);
       
        DOMResult result = new DOMResult();
        MarcXmlWriter writer = new MarcXmlWriter(result, stylesheet);
        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.MarcStreamReader

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.