org.dom4j.tree.DefaultDocument Java Examples
The following examples show how to use
org.dom4j.tree.DefaultDocument.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentPackage.java From olat with Apache License 2.0 | 6 votes |
/** * writes the manifest.xml */ void writeToFile() { final String filename = "imsmanifest.xml"; final OutputFormat format = OutputFormat.createPrettyPrint(); try { VFSLeaf outFile; // file may exist outFile = (VFSLeaf) cpcore.getRootDir().resolve("/" + filename); if (outFile == null) { // if not, create it outFile = cpcore.getRootDir().createChildLeaf("/" + filename); } final DefaultDocument manifestDocument = cpcore.buildDocument(); final XMLWriter writer = new XMLWriter(outFile.getOutputStream(false), format); writer.write(manifestDocument); } catch (final Exception e) { log.error("imsmanifest for ores " + ores.getResourceableId() + "couldn't be written to file.", e); throw new OLATRuntimeException(CPOrganizations.class, "Error writing imsmanifest-file", new IOException()); } }
Example #2
Source File: CPManifest.java From olat with Apache License 2.0 | 6 votes |
/** * @param doc */ public void buildDocument(final DefaultDocument doc) { // Manifest is the root-node of the document, therefore we need to pass the // "doc" final DefaultElement manifestElement = new DefaultElement(CPCore.MANIFEST); manifestElement.add(new DefaultAttribute(CPCore.IDENTIFIER, this.identifier)); manifestElement.add(new DefaultAttribute(CPCore.SCHEMALOCATION, this.schemaLocation)); // manifestElement.setNamespace(this.getNamespace()); //FIXME: namespace doc.add(manifestElement); if (metadata != null) { metadata.buildDocument(manifestElement); } organizations.buildDocument(manifestElement); resources.buildDocument(manifestElement); }
Example #3
Source File: CPManifest.java From olat with Apache License 2.0 | 6 votes |
/** * @param doc */ public void buildDocument(final DefaultDocument doc) { // Manifest is the root-node of the document, therefore we need to pass the // "doc" final DefaultElement manifestElement = new DefaultElement(CPCore.MANIFEST); manifestElement.add(new DefaultAttribute(CPCore.IDENTIFIER, this.identifier)); manifestElement.add(new DefaultAttribute(CPCore.SCHEMALOCATION, this.schemaLocation)); // manifestElement.setNamespace(this.getNamespace()); //FIXME: namespace doc.add(manifestElement); if (metadata != null) { metadata.buildDocument(manifestElement); } organizations.buildDocument(manifestElement); resources.buildDocument(manifestElement); }
Example #4
Source File: ContentPackage.java From olat with Apache License 2.0 | 6 votes |
/** * writes the manifest.xml */ void writeToFile() { final String filename = "imsmanifest.xml"; final OutputFormat format = OutputFormat.createPrettyPrint(); try { VFSLeaf outFile; // file may exist outFile = (VFSLeaf) cpcore.getRootDir().resolve("/" + filename); if (outFile == null) { // if not, create it outFile = cpcore.getRootDir().createChildLeaf("/" + filename); } final DefaultDocument manifestDocument = cpcore.buildDocument(); final XMLWriter writer = new XMLWriter(outFile.getOutputStream(false), format); writer.write(manifestDocument); } catch (final Exception e) { log.error("imsmanifest for ores " + ores.getResourceableId() + "couldn't be written to file.", e); throw new OLATRuntimeException(CPOrganizations.class, "Error writing imsmanifest-file", new IOException()); } }
Example #5
Source File: XMLDocument.java From mts with GNU General Public License v3.0 | 5 votes |
public XMLDocument duplicate() throws Exception { XMLDocument xmlDocument = new XMLDocument(); xmlDocument.setXMLFile(this.getXMLFile()); xmlDocument.setXMLSchema(this.getXMLSchema()); xmlDocument.document = new DefaultDocument(this.document.getRootElement().createCopy()); return xmlDocument; }
Example #6
Source File: XmlUtils.java From iaf with Apache License 2.0 | 5 votes |
public static String getAdapterSite(Object document) throws SAXException, IOException, TransformerException { String input; if (document instanceof DefaultDocument) { DefaultDocument defaultDocument = (DefaultDocument) document; input = defaultDocument.asXML(); } else { input = document.toString(); } return getAdapterSite(input, null); }
Example #7
Source File: CPCore.java From olat with Apache License 2.0 | 5 votes |
/** * Returns the DefaultDocument of this CP * * @return the xml Document of this CP */ public DefaultDocument buildDocument() { // if (doc != null) return doc; final DefaultDocument newDoc = new DefaultDocument(); rootNode.buildDocument(newDoc); return newDoc; }
Example #8
Source File: CPManagerImpl.java From olat with Apache License 2.0 | 5 votes |
/** */ @Override public ContentPackage load(final VFSContainer directory, final OLATResourceable ores) { final XMLParser parser = new XMLParser(); ContentPackage cp; final VFSLeaf file = (VFSLeaf) directory.resolve("imsmanifest.xml"); if (file != null) { try { final DefaultDocument doc = (DefaultDocument) parser.parse(file.getInputStream(), false); cp = new ContentPackage(doc, directory, ores); // If a wiki is imported or a new cp created, set a unique orga // identifier. if (cp.getLastError() == null) { if (cp.isOLATContentPackage() && CPCore.OLAT_ORGANIZATION_IDENTIFIER.equals(cp.getFirstOrganizationInManifest().getIdentifier())) { setUniqueOrgaIdentifier(cp); } } } catch (final OLATRuntimeException e) { cp = new ContentPackage(null, directory, ores); log.error("Reading imsmanifest failed. Dir: " + directory.getName() + ". Ores: " + ores.getResourceableId(), e); cp.setLastError("Exception reading XML for IMS CP: invalid xml-file ( " + directory.getName() + ")"); } } else { cp = new ContentPackage(null, directory, ores); cp.setLastError("Exception reading XML for IMS CP: IMS-Manifest not found in " + directory.getName()); log.error("IMS manifiest xml couldn't be found in dir " + directory.getName() + ". Ores: " + ores.getResourceableId(), null); throw new OLATRuntimeException(this.getClass(), "The imsmanifest.xml file was not found.", new IOException()); } return cp; }
Example #9
Source File: CPCore.java From olat with Apache License 2.0 | 5 votes |
/** * Returns the DefaultDocument of this CP * * @return the xml Document of this CP */ public DefaultDocument buildDocument() { // if (doc != null) return doc; final DefaultDocument newDoc = new DefaultDocument(); rootNode.buildDocument(newDoc); return newDoc; }
Example #10
Source File: CPManagerImpl.java From olat with Apache License 2.0 | 5 votes |
/** */ @Override public ContentPackage load(final VFSContainer directory, final OLATResourceable ores) { final XMLParser parser = new XMLParser(); ContentPackage cp; final VFSLeaf file = (VFSLeaf) directory.resolve("imsmanifest.xml"); if (file != null) { try { final DefaultDocument doc = (DefaultDocument) parser.parse(file.getInputStream(), false); cp = new ContentPackage(doc, directory, ores); // If a wiki is imported or a new cp created, set a unique orga // identifier. if (cp.getLastError() == null) { if (cp.isOLATContentPackage() && CPCore.OLAT_ORGANIZATION_IDENTIFIER.equals(cp.getFirstOrganizationInManifest().getIdentifier())) { setUniqueOrgaIdentifier(cp); } } } catch (final OLATRuntimeException e) { cp = new ContentPackage(null, directory, ores); log.error("Reading imsmanifest failed. Dir: " + directory.getName() + ". Ores: " + ores.getResourceableId(), e); cp.setLastError("Exception reading XML for IMS CP: invalid xml-file ( " + directory.getName() + ")"); } } else { cp = new ContentPackage(null, directory, ores); cp.setLastError("Exception reading XML for IMS CP: IMS-Manifest not found in " + directory.getName()); log.error("IMS manifiest xml couldn't be found in dir " + directory.getName() + ". Ores: " + ores.getResourceableId(), null); throw new OLATRuntimeException(this.getClass(), "The imsmanifest.xml file was not found.", new IOException()); } return cp; }
Example #11
Source File: CPCore.java From olat with Apache License 2.0 | 4 votes |
public CPCore(final DefaultDocument doc, final VFSContainer rootDir) { this.doc = doc; this.rootDir = rootDir; errors = new Vector<String>(); buildTree(); }
Example #12
Source File: ContentPackage.java From olat with Apache License 2.0 | 4 votes |
protected DefaultDocument getDocument() { return cpcore.buildDocument(); }
Example #13
Source File: CPManagerImpl.java From olat with Apache License 2.0 | 4 votes |
/** */ @Override public DefaultDocument getDocument(final ContentPackage cp) { return cp.getDocument(); }
Example #14
Source File: ContentPackage.java From olat with Apache License 2.0 | 4 votes |
ContentPackage(final DefaultDocument doc, final VFSContainer parent, final OLATResourceable ores) { this.cpcore = new CPCore(doc, parent); this.ores = ores; }
Example #15
Source File: ContentPackage.java From olat with Apache License 2.0 | 4 votes |
ContentPackage(final DefaultDocument doc, final VFSContainer parent, final OLATResourceable ores) { this.cpcore = new CPCore(doc, parent); this.ores = ores; }
Example #16
Source File: CPManagerImpl.java From olat with Apache License 2.0 | 4 votes |
/** */ @Override public DefaultDocument getDocument(final ContentPackage cp) { return cp.getDocument(); }
Example #17
Source File: ContentPackage.java From olat with Apache License 2.0 | 4 votes |
protected DefaultDocument getDocument() { return cpcore.buildDocument(); }
Example #18
Source File: CPCore.java From olat with Apache License 2.0 | 4 votes |
public CPCore(final DefaultDocument doc, final VFSContainer rootDir) { this.doc = doc; this.rootDir = rootDir; errors = new Vector<String>(); buildTree(); }
Example #19
Source File: XMLDoc.java From mts with GNU General Public License v3.0 | 4 votes |
public XMLDoc duplicate() throws Exception { XMLDoc xmlDocument = new XMLDoc(); xmlDocument.setXMLFile(this.getXMLFile()); xmlDocument.document = new DefaultDocument(this.document.getRootElement().createCopy()); return xmlDocument; }
Example #20
Source File: CPManager.java From olat with Apache License 2.0 | 2 votes |
/** * Returns the DefaultDocument of the ContentPackage cp * * @return the xml Document of the cp */ public abstract DefaultDocument getDocument(ContentPackage cp);
Example #21
Source File: CPManager.java From olat with Apache License 2.0 | 2 votes |
/** * Returns the DefaultDocument of the ContentPackage cp * * @return the xml Document of the cp */ public abstract DefaultDocument getDocument(ContentPackage cp);