/** * Create blank Document, and insert root element with given name. */ public final static Document newDocument(String rootElementName) throws ParserConfigurationException { Document doc = newDocument(); doc.appendChild(doc.createElement(rootElementName)); return doc; }
/** * Create blank Document, and insert root element with given name. */ public final static Document newDocument(String rootElementName) throws ParserConfigurationException { Document doc = newDocument(); doc.appendChild(doc.createElement(rootElementName)); return doc; }
/** * Perform XSL transformations using given Documents and return new Document. */ public final static Document transform(Document xml, Document xsl) throws ParserConfigurationException, TransformerException { try { Document result = newDocument(); TransformerFactory factory = TransformerFactory.newInstance(); Transformer t = factory.newTransformer(new DOMSource(xsl)); t.transform(new DOMSource(xml), new DOMResult(result)); return result; } catch (TransformerConfigurationException tce) { throw new TransformerException(tce); } } }
/** * Perform XSL transformations using given Documents and return new Document. */ public final static Document transform(Document xml, Document xsl) throws ParserConfigurationException, TransformerException { try { Document result = newDocument(); TransformerFactory factory = TransformerFactory.newInstance(); Transformer t = factory.newTransformer(new DOMSource(xsl)); t.transform(new DOMSource(xml), new DOMResult(result)); return result; } catch (TransformerConfigurationException tce) { throw new TransformerException(tce); } } }
/** * Save properties to XML Document. */ public Document saveToDocument() throws ParserConfigurationException { Document doc = XMLUtils.newDocument("property-set"); Iterator keys = getKeys().iterator(); while (keys.hasNext()) { String key = (String) keys.next(); int type = getType(key); Object value = get(type, key); saveValue(doc, key, type, value); } return doc; }