Package javax.xml.transform.dom

Examples of javax.xml.transform.dom.DOMResult


     *
     * @param source the source to get the root element from
     * @return the root element
     */
    private Element getRootElement(Source source) throws TransformerException {
        DOMResult domResult = new DOMResult();
        transform(source, domResult);
        Document document = (Document) domResult.getNode();
        return document.getDocumentElement();
    }
View Full Code Here


            return xpathFactory.newXPath();
        }
    }

    private Element getRootElement(Source source) throws TransformerException {
        DOMResult domResult = new DOMResult();
        transformerHelper.transform(source, domResult);
        Document document = (Document) domResult.getNode();
        return document.getDocumentElement();
    }
View Full Code Here

        Class<?> parameterType = parameter.getParameterType();
        if (parameterType.isAssignableFrom(requestPayload.getClass())) {
            return requestPayload;
        }
        if (DOMSource.class.isAssignableFrom(parameterType)) {
            DOMResult domResult = new DOMResult();
            transform(requestPayload, domResult);
            Node node = domResult.getNode();
            if (node.getNodeType() == Node.DOCUMENT_NODE) {
                return new DOMSource(((Document) node).getDocumentElement());
            }
            else {
                return new DOMSource(domResult.getNode());
            }
        }
        else if (SAXSource.class.isAssignableFrom(parameterType)) {
            ByteArrayInputStream bis = convertToByteArrayInputStream(requestPayload);
            InputSource inputSource = new InputSource(bis);
View Full Code Here

    protected Node resolveRequestPayloadArgument(MethodParameter parameter, Source requestPayload) throws Exception {
        if (requestPayload instanceof DOMSource) {
            return resolveArgumentDomSource(parameter, (DOMSource) requestPayload);
        }
        else {
            DOMResult domResult = new DOMResult();
            transform(requestPayload, domResult);
            DOMSource domSource = new DOMSource(domResult.getNode());
            return resolveArgumentDomSource(parameter, domSource);
        }
    }
View Full Code Here

    @Test
    public void testNamespacesPrefixes() throws Exception {
        saajReader.setFeature("http://xml.org/sax/features/namespaces", true);
        saajReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
        DOMResult result = new DOMResult();
        Source source = new SAXSource(saajReader, new InputSource());
        transformer.transform(source, result);
        DOMResult expected = new DOMResult();
        transformer.transform(new DOMSource(message.getSOAPPart().getEnvelope()), expected);
        assertXMLEqual((Document) expected.getNode(), (Document) result.getNode());
    }
View Full Code Here

    @Test
    public void testNamespacesNoPrefixes() throws Exception {
        saajReader.setFeature("http://xml.org/sax/features/namespaces", true);
        saajReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
        DOMResult result = new DOMResult();
        Source source = new SAXSource(saajReader, new InputSource());
        transformer.transform(source, result);
        DOMResult expected = new DOMResult();
        transformer.transform(new DOMSource(message.getSOAPPart().getEnvelope()), expected);
        assertXMLEqual((Document) expected.getNode(), (Document) result.getNode());
    }
View Full Code Here

        Source xml = new StreamSource(report);
        Source xslt = new StreamSource(new File(cd,
                "src/main/resources/org/jbehave/jenkins/"+new JBehaveInputMetric().getXslName()));

        Result resultOutput = new StreamResult(System.out);
        DOMResult result = new DOMResult();

        Transformer transformer = TransformerFactory.newInstance().newTransformer(xslt);
        transformer.transform(xml, result);
        transformer.transform(xml, resultOutput);
        return (Document) result.getNode();
    }
View Full Code Here

            if (callback.result != null) {
                return callback.result;
            }
            else {
                // we have no other option than to transform
                DOMResult domResult = new DOMResult();
                transformerHelper.transform(source, domResult);
                Document document = (Document) domResult.getNode();
                return QNameUtils.getQNameForNode(document.getDocumentElement());
            }
        }
        catch (TransformerException ex) {
            throw ex;
View Full Code Here

        return expression.evaluateAsString(payloadElement);
    }

    private Element getMessagePayloadElement(WebServiceMessage message) throws TransformerException {
        Transformer transformer = transformerFactory.newTransformer();
        DOMResult domResult = new DOMResult();
        transformer.transform(message.getPayloadSource(), domResult);
        return (Element) domResult.getNode().getFirstChild();
    }
View Full Code Here

        Source xml = new StreamSource(report);
        Source xslt = new StreamSource(new File(cd,
                "src/main/resources/org/jbehave/hudson/"+new JBehaveInputMetric().getXslName()));

        Result resultOutput = new StreamResult(System.out);
        DOMResult result = new DOMResult();

        Transformer transformer = TransformerFactory.newInstance().newTransformer(xslt);
        transformer.transform(xml, result);
        transformer.transform(xml, resultOutput);
        return (Document) result.getNode();
    }
View Full Code Here

TOP

Related Classes of javax.xml.transform.dom.DOMResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.