当前位置: 首页>>代码示例>>Java>>正文


Java MarcXmlWriter类代码示例

本文整理汇总了Java中org.marc4j.MarcXmlWriter的典型用法代码示例。如果您正苦于以下问题:Java MarcXmlWriter类的具体用法?Java MarcXmlWriter怎么用?Java MarcXmlWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MarcXmlWriter类属于org.marc4j包,在下文中一共展示了MarcXmlWriter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readMARCRecords

import org.marc4j.MarcXmlWriter; //导入依赖的package包/类
private Sequence readMARCRecords(final MarcReader aReader) throws XPathException {
    final MemTreeBuilder builder = context.getDocumentBuilder();
    final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder);
    final SAXResult saxResult = new SAXResult(receiver);
    final MarcWriter writer = new MarcXmlWriter(saxResult);

    writer.setConverter(new AnselToUnicode());

    while (aReader.hasNext()) {
        final Record record = aReader.next();
        final String recordId = record.getControlNumber();

        if (LOGGER.isDebugEnabled() && recordId != null) {
            LOGGER.debug("Reading MARC record: " + recordId);
        }

        writer.write(record);
    }

    writer.close();

    return (DocumentImpl) receiver.getDocument();
}
 
开发者ID:ksclarke,项目名称:freelib-marc4j-exist,代码行数:24,代码来源:ReadFromFile.java

示例2: generateMarcFromXml

import org.marc4j.MarcXmlWriter; //导入依赖的package包/类
private void generateMarcFromXml(String bibContent, String location, int fileName) throws Exception {
    LOG.info("Docstore dump location : " + location);
    InputStream input = new ByteArrayInputStream(bibContent.getBytes());
    File file = new File(location + "/" + fileName + ".mrk");
    if (!file.exists()) {
        file.getParentFile().mkdirs();
        file.createNewFile();
    }
    FileOutputStream fileOutputStream = new FileOutputStream(file);
    MarcXmlReader marcXmlReader = new MarcXmlReader(input);
    MarcXmlWriter marcXmlWriter = new MarcXmlWriter(fileOutputStream, true);

    while (marcXmlReader.hasNext()) {
        Record record = marcXmlReader.next();
        marcXmlWriter.write(record);
    }
    marcXmlWriter.close();
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:19,代码来源:OleDocstoreDumpService.java

示例3: toMarcXml

import org.marc4j.MarcXmlWriter; //导入依赖的package包/类
/** Converts Marc21 to MarcXML */
public static Document toMarcXml(byte[] marc21, String charset) {
    MarcReader reader = new MarcStreamReader(new ByteArrayInputStream(marc21), charset);
    DOMResult result = new DOMResult();
    MarcXmlWriter writer = new MarcXmlWriter(result);
    if (reader.hasNext()) {
        Record record = reader.next();
        writer.write(record);
    }
    writer.close();

    Document retval = (Document) result.getNode();
    return retval;
}
 
开发者ID:proarc,项目名称:proarc,代码行数:15,代码来源:Z3950Client.java

示例4: convertRawMarcToXML

import org.marc4j.MarcXmlWriter; //导入依赖的package包/类
/**
 * @param inputFile
 * @return converted marc xml File Name
 * @throws java.io.FileNotFoundException This method takes in a raw marc file and converts into a marc xml file.
 */
public String convertRawMarcToXML(File inputFile) throws FileNotFoundException {
    InputStream input = new FileInputStream(inputFile);
    String fileName = inputFile.getName().replace(".mrc", ".xml");
    FileOutputStream fileOutputStream = new FileOutputStream(new File(fileName));
    MarcReader reader = new MarcStreamReader(input);
    MarcWriter writer = new MarcXmlWriter(fileOutputStream, true);

    while (reader.hasNext()) {
        Record record = reader.next();
        writer.write(record);
    }
    writer.close();
    return fileName;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:20,代码来源:MarcXMLConverter.java

示例5: convert

import org.marc4j.MarcXmlWriter; //导入依赖的package包/类
/**
 * @param content
 * @return converted marc xml
 */
public String convert(String content) {
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content.getBytes());
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

    MarcReader reader = new MarcStreamReader(byteArrayInputStream);
    MarcWriter writer = new MarcXmlWriter(byteArrayOutputStream, true);

    while (reader.hasNext()) {
        Record record = reader.next();
        writer.write(record);
    }
    writer.close();
    return new String(byteArrayOutputStream.toByteArray());
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:19,代码来源:MarcXMLConverter.java

示例6: convert

import org.marc4j.MarcXmlWriter; //导入依赖的package包/类
public String convert(String content) {
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content.getBytes());
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    MarcWriter writer = new MarcXmlWriter(byteArrayOutputStream, true);


    Record record;
    String inline;

    BufferedReader br = null;
    br = new BufferedReader(new InputStreamReader(byteArrayInputStream));
    record = marcFactory.newRecord();

    try {
        while ((inline = br.readLine()) != null) {

            if (inline.equals("") || inline.startsWith(" ")) {
                writer.write(record);
                record = marcFactory.newRecord();
            } else {
                record = addLineToRecord(inline, record);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    writer.write(record);
    writer.close();
    return new String(byteArrayOutputStream.toByteArray());

}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:33,代码来源:MRKToMARCXMLConverter.java

示例7: convert

import org.marc4j.MarcXmlWriter; //导入依赖的package包/类
public String convert(String content) {
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content.getBytes());
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    MarcWriter writer = new MarcXmlWriter(byteArrayOutputStream, true);

    Record record;
    String inline;

    BufferedReader br = null;
    br = new BufferedReader(new InputStreamReader(byteArrayInputStream));
    record = marcFactory.newRecord();

    try {
        while ((inline = br.readLine()) != null) {
            if (inline.equals("") || inline.startsWith(" ")) {
                writer.write(record);
                record = marcFactory.newRecord();
            } else {
                record = addLineToRecord(inline, record);
            }
        }
    } catch (IOException e) {

    }

    writer.write(record);
    writer.close();
    return new String(byteArrayOutputStream.toByteArray());

}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:31,代码来源:MRKToMARCXMLConverter.java


注:本文中的org.marc4j.MarcXmlWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。