Package org.apache.camel.converter.jaxp

Examples of org.apache.camel.converter.jaxp.XmlConverter


            log.debug(this + " using schema resource: " + resource);
        }
        XsltBuilder xslt = newInstance(XsltBuilder.class);

        // lets allow the converter to be configured
        XmlConverter converter = null;
        String converterName = getAndRemoveParameter(parameters, "converter", String.class);       
        if (converterName != null) {
            converter = mandatoryLookup(converterName, XmlConverter.class);
        }
        if (converter == null) {
View Full Code Here


        return toInputStream(toString(buffer), exchange);
    }

    @Converter
    public static InputStream toInputStrean(DOMSource source) throws TransformerException, IOException {
        XmlConverter xmlConverter = createXmlConverter();
        ByteArrayInputStream bais = new ByteArrayInputStream(xmlConverter.toString(source).getBytes());
        return bais;
    }
View Full Code Here

        return bais;
    }

    private static XmlConverter createXmlConverter() {
        if (xmlConverter == null) {
            xmlConverter = new XmlConverter();
        }
        return xmlConverter;
    }
View Full Code Here

        //Helper class
    }
   
    @Converter
    public static String cxfPayloadToString(final CxfPayload payload) {
        XmlConverter converter = new XmlConverter();
        StringBuilder buf = new StringBuilder();
        for (Object element : payload.getBody()) {
            String elementString = "";
            try {
                elementString = converter.toString((Element)element, null);
            } catch (TransformerException e) {
                elementString = element.toString();
            }
            buf.append(elementString);
        }
View Full Code Here

                        CxfPayload<SoapHeader> requestPayload = exchange.getIn().getBody(CxfPayload.class);
                        List<Element> inElements = requestPayload.getBody();
                        List<Element> outElements = new ArrayList<Element>();
                        // You can use a customer toStringConverter to turn a CxfPayLoad message into String as you want                       
                        String request = exchange.getIn().getBody(String.class);
                        XmlConverter converter = new XmlConverter();
                        String documentString = ECHO_RESPONSE;
                        if (inElements.get(0).getLocalName().equals("echoBoolean")) {
                            documentString = ECHO_BOOLEAN_RESPONSE;
                            assertEquals("Get a wrong request", ECHO_BOOLEAN_REQUEST, request);
                        } else {
                            assertEquals("Get a wrong request", ECHO_REQUEST, request);
                        }
                        Document outDocument = converter.toDOMDocument(documentString);
                        outElements.add(outDocument.getDocumentElement());
                        // set the payload header with null
                        CxfPayload<SoapHeader> responsePayload = new CxfPayload<SoapHeader>(null, outElements);
                        exchange.getOut().setBody(responsePayload);
                    }
View Full Code Here

    public List<T> getHeaders() {
        return headers;
    }
   
    public String toString() {
        XmlConverter converter = new XmlConverter();
        StringBuilder buf = new StringBuilder();
        buf.append(getClass().getName());
        buf.append(" headers: " + headers);
        // go through the list of element and turn it into String
        if (body == null) {
            buf.append("body: " + body);
        } else {
            buf.append("body: [ ");
            for (Element element : body) {
                String elementString = "";
                try {
                    elementString = converter.toString(element, null);
                } catch (TransformerException e) {
                    elementString = element.toString();
                }
                buf.append("[" + elementString + "]");
            }
View Full Code Here

    public static String elementToString(Element element) throws Exception {
        Map<String, String> namespaces = new HashMap<String, String>();
        visitNodesForNameSpace(element, namespaces);
        W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
        writeElement(element, writer, namespaces);
        XmlConverter converter = new XmlConverter();
        return converter.toString(converter.toSource(writer.getDocument()), null);
    }
View Full Code Here

            log.debug(this + " using schema resource: " + resource);
        }
        XsltBuilder xslt = getCamelContext().getInjector().newInstance(XsltBuilder.class);

        // lets allow the converter to be configured
        XmlConverter converter = resolveAndRemoveReferenceParameter(parameters, "converter", XmlConverter.class);
        if (converter == null) {
            converter = getXmlConverter();
        }
        if (converter != null) {
            xslt.setConverter(converter);
View Full Code Here

            try {
                Document cacheValueDocument = exchange.getContext().getTypeConverter()
                    .convertTo(Document.class, exchange, cis);

                // Create/setup the Transformer
                XmlConverter xmlConverter = new XmlConverter();
                String xslString = IOConverter.toString(new File("./src/main/resources/xpathreplacer.xsl"), exchange);
                xslString = xslString.replace("##match_token##", xpath);
                Source xslSource = xmlConverter.toStreamSource(new StringReader(xslString));
                TransformerFactory transformerFactory = xmlConverter.createTransformerFactory();
                Transformer transformer = transformerFactory.newTransformer(xslSource);
                source = xmlConverter.toDOMSource(document);
                result = new DOMResult();

                transformer.setParameter("cacheValue", cacheValueDocument);
                transformer.transform(source, result);
            } finally {
View Full Code Here

                        CxfPayload<SoapHeader> payload = exchange.getIn().getBody(CxfPayload.class);
                        List<Source> elements = payload.getBodySources();
                        assertNotNull("We should get the elements here", elements);
                        assertEquals("Get the wrong elements size", 1, elements.size());
                       
                        Element el = new XmlConverter().toDOMElement(elements.get(0));
                        elements.set(0, new DOMSource(el));
                        assertEquals("Get the wrong namespace URI", "http://camel.apache.org/pizza/types",
                                el.getNamespaceURI());
                           
                        List<SoapHeader> headers = payload.getHeaders();
View Full Code Here

TOP

Related Classes of org.apache.camel.converter.jaxp.XmlConverter

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.