Search in sources :

Example 96 with Document

use of iso.std.iso._20022.tech.xsd.pain_001_001.Document in project mycore by MyCoRe-Org.

the class MCRBase method createXML.

/**
 * This method create a XML stream for all object data.
 *
 * @exception MCRException
 *                if the content of this class is not valid
 * @return a JDOM Document with the XML data of the object as byte array
 */
public Document createXML() throws MCRException {
    validate();
    Element elm = new Element(getRootTagName());
    Document doc = new Document(elm);
    elm.addNamespaceDeclaration(XSI_NAMESPACE);
    elm.addNamespaceDeclaration(XLINK_NAMESPACE);
    elm.setAttribute("noNamespaceSchemaLocation", mcr_schema, XSI_NAMESPACE);
    elm.setAttribute("ID", mcr_id.toString());
    if (mcr_label != null) {
        elm.setAttribute("label", mcr_label);
    }
    elm.setAttribute("version", mcr_version);
    return doc;
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document)

Example 97 with Document

use of iso.std.iso._20022.tech.xsd.pain_001_001.Document in project mycore by MyCoRe-Org.

the class MCRDerivate method createXML.

/**
 * This methode create a XML stream for all object data.
 *
 * @exception MCRException
 *                if the content of this class is not valid
 * @return a JDOM Document with the XML data of the object as byte array
 */
@Override
public final org.jdom2.Document createXML() throws MCRException {
    Document doc = super.createXML();
    Element elm = doc.getRootElement();
    elm.addContent(mcr_derivate.createXML());
    elm.addContent(mcr_service.createXML());
    return doc;
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document)

Example 98 with Document

use of iso.std.iso._20022.tech.xsd.pain_001_001.Document in project mycore by MyCoRe-Org.

the class MCRStoreBrowserRequest method buildResponseXML.

/**
 * Builds the xml output to be rendered as response
 */
Document buildResponseXML() throws Exception {
    File dir = getRequestedDirectory();
    String[] children = dir.list();
    Element xml = new Element("storeBrowser");
    if (children != null)
        for (String child : children) {
            xml.addContent(buildXML(child));
        }
    return new Document(xml);
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) File(java.io.File)

Example 99 with Document

use of iso.std.iso._20022.tech.xsd.pain_001_001.Document in project mycore by MyCoRe-Org.

the class MCRFileCollection method readAdditionalData.

private void readAdditionalData() throws IOException {
    FileObject src = VFS.getManager().resolveFile(fo, dataFile);
    if (!src.exists()) {
        LOGGER.warn("Metadata file is missing, repairing metadata...");
        data = new Element("collection");
        new Document(data);
        repairMetadata();
    }
    try {
        data = new MCRVFSContent(src).asXML().getRootElement();
    } catch (JDOMException | SAXException e) {
        throw new IOException(e);
    }
}
Also used : Element(org.jdom2.Element) FileObject(org.apache.commons.vfs2.FileObject) IOException(java.io.IOException) Document(org.jdom2.Document) JDOMException(org.jdom2.JDOMException) MCRVFSContent(org.mycore.common.content.MCRVFSContent) SAXException(org.xml.sax.SAXException)

Example 100 with Document

use of iso.std.iso._20022.tech.xsd.pain_001_001.Document in project mycore by MyCoRe-Org.

the class MCRXSLTransformationTest method transform.

@Test
public void transform() {
    Element root = new Element("root");
    Document in = new Document(root);
    root.addContent(new Element("child").setAttribute("hasChildren", "no"));
    Document out = MCRXSLTransformation.transform(in, stylesheet.getAbsolutePath());
    assertTrue("Input not the same as Output", MCRXMLHelper.deepEqual(in, out));
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) Test(org.junit.Test)

Aggregations

Document (org.jdom2.Document)391 Element (org.jdom2.Element)243 Test (org.junit.Test)104 SAXBuilder (org.jdom2.input.SAXBuilder)84 IOException (java.io.IOException)72 File (java.io.File)56 XMLOutputter (org.jdom2.output.XMLOutputter)56 JDOMException (org.jdom2.JDOMException)44 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)34 MCRNodeBuilder (org.mycore.common.xml.MCRNodeBuilder)25 DocType (org.jdom2.DocType)24 ArrayList (java.util.ArrayList)22 MCRContent (org.mycore.common.content.MCRContent)22 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)22 MCRException (org.mycore.common.MCRException)21 Document (com.google.cloud.language.v1.Document)20 HashMap (java.util.HashMap)19 Attribute (org.jdom2.Attribute)19 MCRObject (org.mycore.datamodel.metadata.MCRObject)19 URL (java.net.URL)18