Search in sources :

Example 21 with MCRJDOMContent

use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.

the class MCRNormalizeUnicodeTransformer method process.

public Document process(Document xml) throws IOException, JDOMException, SAXException {
    if (stylesheet == null)
        return xml.clone();
    MCRContent source = new MCRJDOMContent(xml);
    MCRContent transformed = MCRXSL2XMLTransformer.getInstance("xsl/" + stylesheet).transform(source);
    MCRContent normalized = new MCRNormalizeUnicodeTransformer().transform(transformed);
    return normalized.asXML();
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) MCRContent(org.mycore.common.content.MCRContent)

Example 22 with MCRJDOMContent

use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.

the class MCRMailEventHandler method handleDerivateEvent.

private void handleDerivateEvent(MCREvent evt, MCRDerivate der) {
    MCRContent xml = new MCRJDOMContent(der.createXML());
    handleEvent(evt, xml, der.getId().toString());
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) MCRContent(org.mycore.common.content.MCRContent)

Example 23 with MCRJDOMContent

use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.

the class MCRMailEventHandler method handleObjectEvent.

private void handleObjectEvent(MCREvent evt, MCRObject obj) {
    MCRContent xml = new MCRJDOMContent(obj.createXML());
    handleEvent(evt, xml, obj.getId().toString());
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) MCRContent(org.mycore.common.content.MCRContent)

Example 24 with MCRJDOMContent

use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.

the class MCRMailEventHandler method handlePathEvent.

private void handlePathEvent(MCREvent evt, Path file, BasicFileAttributes attrs) {
    if (!(file instanceof MCRPath)) {
        return;
    }
    MCRPath path = MCRPath.toMCRPath(file);
    MCRContent xml;
    try {
        xml = new MCRJDOMContent(MCRPathXML.getFileXML(path, attrs));
        handleEvent(evt, xml, path.toString());
    } catch (IOException e) {
        LOGGER.error("Error while generating mail for {}", file, e);
    }
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) IOException(java.io.IOException) MCRPath(org.mycore.datamodel.niofs.MCRPath) MCRContent(org.mycore.common.content.MCRContent)

Example 25 with MCRJDOMContent

use of org.mycore.common.content.MCRJDOMContent in project mycore by MyCoRe-Org.

the class MCRXSL2XMLTransformer method getTransformedContent.

@Override
protected MCRContent getTransformedContent(MCRContent source, XMLReader reader, TransformerHandler transformerHandler) throws IOException, SAXException {
    JDOMResult result = new JDOMResult();
    transformerHandler.setResult(result);
    // Parse the source XML, and send the parse events to the
    // TransformerHandler.
    reader.parse(source.getInputSource());
    Document resultDoc = getDocument(result);
    if (resultDoc == null) {
        throw new MCRConfigurationException("Stylesheets " + Arrays.asList(templateSources) + " does not return any content for " + source.getSystemId());
    }
    return new MCRJDOMContent(resultDoc);
}
Also used : JDOMResult(org.jdom2.transform.JDOMResult) MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) MCRConfigurationException(org.mycore.common.config.MCRConfigurationException) Document(org.jdom2.Document)

Aggregations

MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)54 Document (org.jdom2.Document)33 Element (org.jdom2.Element)28 Test (org.junit.Test)21 MCRContent (org.mycore.common.content.MCRContent)20 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)6 IOException (java.io.IOException)5 File (java.io.File)4 MCRParameterCollector (org.mycore.common.xsl.MCRParameterCollector)4 MCRDerivate (org.mycore.datamodel.metadata.MCRDerivate)4 MCRObject (org.mycore.datamodel.metadata.MCRObject)4 Date (java.util.Date)3 JDOMException (org.jdom2.JDOMException)3 MCRContentTransformer (org.mycore.common.content.transformer.MCRContentTransformer)3 MCRPath (org.mycore.datamodel.niofs.MCRPath)3 FileObject (org.apache.commons.vfs2.FileObject)2 XMLOutputter (org.jdom2.output.XMLOutputter)2 MCRException (org.mycore.common.MCRException)2 MCRPersistenceException (org.mycore.common.MCRPersistenceException)2 MCRFileContent (org.mycore.common.content.MCRFileContent)2