Skip to end of banner
Go to start of banner

MODOAIPMH-50 Spike: Determine best approach

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

Questions:

  1. find out if the marc4j supports conversion from MARC Json to MARC XML.
  2. define best mapping approach with XSLT post-processing or custom converter.

Q.1

During the analysis, we found that marc4j  support  mapping MARC Json (examples) to MARC XML (schema) out of the box. Consequently, usage of this library will accelerate the development.

Code snippet

transform MARC Json file into MARC Xml  with org.w3c.dom.Node representation;


private static Node fromMarkJson2XML(String path) throws IOException, TransformerException {
InputStream fileInputStream = new FileInputStream(path);
MarcReader marcJsonReader = new MarcJsonReader(fileInputStream);
MarcXmlWriter marcXmlWriter = null;
DOMResult domResult = new DOMResult();
marcXmlWriter = new MarcXmlWriter(domResult);
while (marcJsonReader.hasNext()) {
Record record = marcJsonReader.next();
marcXmlWriter.write(record);
}
marcXmlWriter.close();
fileInputStream.close();
return domResult.getNode();

}


Q.2

Initially we were considering 2 approaches: XSLT post-processing or custom converter.

Approaches:

  1. Custom Java mapper (MARC4J Model to DC Jaxb Object)
    Benefits:
    • can have better performance

  Drawbacks:

    • hard to introduce new formats
    • need to spend time on own implementation

2. Use XSLT to transform MARC4J Model to DC
Benefits :

Drawbacks:

    • no way(hard) to affect performance.


Suggest to choose the second approach because:

  • usage of this library will accelerate the development
  • no proof that 1st approach will have better performance
  • easily implement new formats.


Code snippet

to apply XSLT stylesheet :

replace from previous code snippet

DOMResult domResult = new DOMResult();

MarcXmlWriter marcXmlWriter = new MarcXmlWriter(domResult);

to

DOMResult domResult = new DOMResult();

Source stylesheet = new StreamSource(stylesheetSource); //stylesheetSource - xsl stylesheet URL

MarcXmlWriter marcXmlWriter = new MarcXmlWriter(domResult, stylesheet);


  • No labels