Search in sources :

Example 1 with MCRXMLContent

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

the class MCRToPrettyXML method transform.

@Override
public MCRContent transform(MCRContent source) throws IOException {
    MCRXMLContent content;
    try {
        content = (source instanceof MCRXMLContent ? (MCRXMLContent) source : new MCRJDOMContent(source.asXML()));
    } catch (JDOMException | SAXException e) {
        throw new IOException(e);
    }
    if (content != source) {
        content.setName(source.getName());
        content.setLastModified(source.lastModified());
    }
    content.setFormat(Format.getPrettyFormat().setEncoding(getEncoding()));
    return content;
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) MCRXMLContent(org.mycore.common.content.MCRXMLContent) IOException(java.io.IOException) JDOMException(org.jdom2.JDOMException) SAXException(org.xml.sax.SAXException)

Aggregations

IOException (java.io.IOException)1 JDOMException (org.jdom2.JDOMException)1 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)1 MCRXMLContent (org.mycore.common.content.MCRXMLContent)1 SAXException (org.xml.sax.SAXException)1