Package org.apache.camel.converter.jaxp

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


                    public void process(Exchange exchange) throws Exception {
                        CxfPayload<?> 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" , elements.size(), 1);
                        Element el = new XmlConverter().toDOMElement(elements.get(0));
                        assertEquals("Get the wrong namespace URI" , el.getNamespaceURI(), "http://cxf.component.camel.apache.org/");
                    }
                   
                })
                .to(serviceEndpointURI);
View Full Code Here


                from(getFromEndpointUri()).process(new Processor() {
                    public void process(final Exchange exchange) {
                        Message in = exchange.getIn();
                        Node node = in.getBody(Node.class);
                        assertNotNull(node);
                        XmlConverter xmlConverter = new XmlConverter();
                        // Put the result back
                        exchange.getOut().setBody(xmlConverter.toSource(RESPONSE));
                    }
                });
            }
        };
    }
View Full Code Here

                       
                        CxfPayload<?> 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" , elements.size(), 1);
                        Element el = new XmlConverter().toDOMElement(elements.get(0));
                        assertEquals("Get the wrong namespace URI" , el.getNamespaceURI(), "http://cxf.component.camel.apache.org/");
                    }
                   
                })
                .to(serviceEndpointURI);
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

                        List<String> params = new ArrayList<String>();

                        if (message != null) {
                            // convert CxfPayload to list of objects any way you like
                            Element element = new XmlConverter().toDOMElement(message.getBody().get(0));
                            params.add(element.getFirstChild().getTextContent());
                        }
                           
                        // replace the body
                        exchange.getIn().setBody(params);
View Full Code Here

                        CxfPayload<?> 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" , elements.size(), 1);
                       
                        Element el = new XmlConverter().toDOMElement(elements.get(0));
                        assertEquals("Get the wrong namespace URI" , el.getNamespaceURI(), "http://cxf.component.camel.apache.org/");
                    }
                   
                })
                .to("cxf:bean:serviceEndpoint?dataFormat=PAYLOAD");
View Full Code Here

        assertEquals("Get unexpected String", EXPECTED_STRING2, getSubElementString(TEST_XML2));
    }
   
    private String getSubElementString(String string) throws Exception {
        InputStream is = new ByteArrayInputStream(string.getBytes("UTF-8"));
        XmlConverter converter = new XmlConverter();
        Element element = converter.toDOMElement(converter.toDOMSource(is));
        Element subElement = (Element)element.getFirstChild();
        return CxfUtils.elementToString(subElement);
       
    }
View Full Code Here

            Map<String, String> ns = new HashMap<String, String>();
            ns.put("ns", MtomTestHelper.SERVICE_TYPES_NS);
            ns.put("xop", MtomTestHelper.XOP_NS);

            XPathUtils xu = new XPathUtils(ns);
            Element body = new XmlConverter().toDOMElement(in.getBody().get(0));
            Element ele = (Element)xu.getValue("//ns:Detail/ns:photo/xop:Include", body,
                                               XPathConstants.NODE);
            String photoId = ele.getAttribute("href").substring(4); // skip "cid:"
            assertEquals(MtomTestHelper.REQ_PHOTO_CID, photoId);
View Full Code Here

        CamelEndpointDispatcher endpoint = CamelContextHelper.mandatoryLookup(getCamelContext(), lookupKey, CamelEndpointDispatcher.class);
        configuration.setEndpointDispatcher(endpoint);
    }

    private void addXmlConverterToConfiguration(Map<String, Object> parameters, SpringWebserviceConfiguration configuration) {
        XmlConverter xmlConverter = new XmlConverter();
        TransformerFactory transformerFactory = resolveAndRemoveReferenceParameter(parameters, "transformerFactory", TransformerFactory.class, null);
        if (transformerFactory != null) {
            xmlConverter.setTransformerFactory(transformerFactory);
        }
        configuration.setXmlConverter(xmlConverter);
    }
View Full Code Here

    public void setTransformerFactory(TransformerFactory transformerFactory) {
        this.transformerFactory = transformerFactory;
    }

    public void afterPropertiesSet() throws Exception {
        xmlConverter = new XmlConverter();
        if (transformerFactory != null) {
            xmlConverter.setTransformerFactory(transformerFactory);
        } else {
            transformerFactory = TransformerFactory.newInstance();
        }
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.