List of usage examples for javax.xml.transform.dom DOMResult getNode
public Node getNode()
From source file:org.springframework.integration.xml.transformer.XsltPayloadTransformer.java
private Document transformDocument(Document documentPayload, Transformer transformer) throws TransformerException { Source source;//w w w . j av a2 s. co m if (this.alwaysUseSourceFactory) { source = this.sourceFactory.createSource(documentPayload); } else { source = new DOMSource(documentPayload); } Result result = this.resultFactory.createResult(documentPayload); if (!DOMResult.class.isAssignableFrom(result.getClass())) { throw new MessagingException( "Document to Document conversion requires a DOMResult-producing ResultFactory implementation."); } DOMResult domResult = (DOMResult) result; transformer.transform(source, domResult); return (Document) domResult.getNode(); }
From source file:org.springframework.oxm.support.AbstractMarshaller.java
/** * Template method for handling {@code DOMResult}s. * <p>This implementation delegates to {@code marshalDomNode}. * @param graph the root of the object graph to marshal * @param domResult the {@code DOMResult} * @throws XmlMappingException if the given object cannot be marshalled to the result * @throws IllegalArgumentException if the {@code domResult} is empty * @see #marshalDomNode(Object, org.w3c.dom.Node) *//*from w w w .j a v a 2s . c o m*/ protected void marshalDomResult(Object graph, DOMResult domResult) throws XmlMappingException { if (domResult.getNode() == null) { domResult.setNode(buildDocument()); } marshalDomNode(graph, domResult.getNode()); }
From source file:org.springframework.ws.wsdl.wsdl11.provider.InliningXsdSchemaTypesProvider.java
private Element getSchemaElement(XsdSchema schema) { try {//ww w . j av a 2s. c o m DOMResult result = new DOMResult(); transform(schema.getSource(), result); Document schemaDocument = (Document) result.getNode(); return schemaDocument.getDocumentElement(); } catch (TransformerException e) { throw new WsdlDefinitionException("Could not transform schema source to Document"); } }
From source file:org.trancecode.xml.saxon.Saxon.java
public static Document asDomDocument(final XdmNode node, final Processor processor) { try {/*from w ww.j a va2 s .com*/ final Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); final DOMResult domResult = new DOMResult(); final XsltTransformer transformer = processor.newXsltCompiler().compile(null).load(); transformer.setSource(node.asSource()); transformer.setDestination(new DOMDestination(document)); transformer.transform(); return (Document) domResult.getNode(); } catch (final Exception e) { throw new IllegalStateException(e); } }
From source file:pl.nask.hsn2.workflow.parser.HWLParser.java
private void createSchema() throws IOException, SAXException { final DOMResult result = new DOMResult(); SchemaOutputResolver outputResolver = new HwlSchemaOutputResolver(result); ctx.generateSchema(outputResolver);// w w w. ja v a 2 s .c o m this.schemaNode = result.getNode(); this.schemaSystemId = result.getSystemId(); Source source = new DOMSource(schemaNode, schemaSystemId); this.schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(source); }
From source file:sernet.gs.scraper.ZIPGSSource.java
private Node parseDocument(InputStream inputstream, String encoding) throws TransformerConfigurationException, IOException, SAXException { InputStreamReader reader = new InputStreamReader(inputstream, encoding); BufferedReader buffRead = new BufferedReader(reader); SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory.newInstance(); TransformerHandler th = stf.newTransformerHandler(); DOMResult dr = new DOMResult(); th.setResult(dr);/*from ww w.j a va 2s . co m*/ Parser parser = new Parser(); parser.setContentHandler(th); parser.parse(new InputSource(buffRead)); Node domRootNode = dr.getNode(); domRootNode.normalize(); buffRead.close(); reader.close(); inputstream.close(); return domRootNode; }