Search in sources :

Example 6 with Namespaces

use of org.apache.camel.builder.xml.Namespaces in project camel by apache.

the class SplitterWithXqureyTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {

        public void configure() {
            // split the message with namespaces defined 
            Namespaces namespaces = new Namespaces("one", "http://camel.apache.org/schema/one");
            from("direct:endpoint").split().xpath("//one:other", namespaces).to("mock:result");
            from("direct:toString").split().xpath("//one:other", namespaces).process(new Processor() {

                public void process(Exchange exchange) throws Exception {
                    Element element = (Element) exchange.getIn().getBody();
                    String message = CxfUtils.elementToString(element);
                    exchange.getOut().setBody(message);
                }
            }).to("mock:result");
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) Namespaces(org.apache.camel.builder.xml.Namespaces) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) Element(org.w3c.dom.Element)

Example 7 with Namespaces

use of org.apache.camel.builder.xml.Namespaces in project camel by apache.

the class XPathWithNamespaceBuilderFilterAndResultTypeTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {

        public void configure() {
            // START SNIPPET: example
            // lets define the namespaces we'll need in our filters
            Namespaces ns = new Namespaces("c", "http://acme.com/cheese").add("xsd", "http://www.w3.org/2001/XMLSchema");
            // now lets create an xpath based Message Filter
            from("direct:start").filter(ns.xpath("/c:person[@name='James']", String.class)).to("mock:result");
        // END SNIPPET: example
        }
    };
}
Also used : Namespaces(org.apache.camel.builder.xml.Namespaces) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 8 with Namespaces

use of org.apache.camel.builder.xml.Namespaces in project camel by apache.

the class XPathWithNamespaceBuilderFilterTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {

        public void configure() {
            // START SNIPPET: example
            // lets define the namespaces we'll need in our filters
            Namespaces ns = new Namespaces("c", "http://acme.com/cheese").add("xsd", "http://www.w3.org/2001/XMLSchema");
            // now lets create an xpath based Message Filter
            from("direct:start").filter(ns.xpath("/c:person[@name='James']")).to("mock:result");
        // END SNIPPET: example
        }
    };
}
Also used : Namespaces(org.apache.camel.builder.xml.Namespaces) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 9 with Namespaces

use of org.apache.camel.builder.xml.Namespaces in project camel by apache.

the class XPathWithNamespacesFilterTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {

        public void configure() {
            // START SNIPPET: example
            Namespaces ns = new Namespaces("c", "http://acme.com/cheese");
            from("direct:start").filter().xpath("/c:person[@name='James']", ns).to("mock:result");
        // END SNIPPET: example
        }
    };
}
Also used : Namespaces(org.apache.camel.builder.xml.Namespaces) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 10 with Namespaces

use of org.apache.camel.builder.xml.Namespaces in project camel by apache.

the class XMLTokenSplitTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        Namespaces ns = new Namespaces("", "http:acme.com");

        @Override
        public void configure() throws Exception {
            // START SNIPPET: e1
            from("file:target/xtokenizer").split().xtokenize("//orders/order", ns).to("mock:split");
            // END SNIPPET: e1
            from("file:target/xtokenizer2").split(body().xtokenize("//orders/order", ns)).to("mock:split");
        }
    };
}
Also used : Namespaces(org.apache.camel.builder.xml.Namespaces) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Aggregations

Namespaces (org.apache.camel.builder.xml.Namespaces)12 RouteBuilder (org.apache.camel.builder.RouteBuilder)10 Element (org.w3c.dom.Element)3 NamespaceAware (org.apache.camel.spi.NamespaceAware)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 Endpoint (org.apache.camel.Endpoint)1 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 ExpressionNode (org.apache.camel.model.ExpressionNode)1