Search in sources :

Example 1 with Namespaces

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

the class CamelNamespaceHandler method injectNamespaces.

protected void injectNamespaces(Element element, Binder<Node> binder) {
    NodeList list = element.getChildNodes();
    Namespaces namespaces = null;
    int size = list.getLength();
    for (int i = 0; i < size; i++) {
        Node child = list.item(i);
        if (child instanceof Element) {
            Element childElement = (Element) child;
            Object object = binder.getJAXBNode(child);
            if (object instanceof NamespaceAware) {
                NamespaceAware namespaceAware = (NamespaceAware) object;
                if (namespaces == null) {
                    namespaces = new Namespaces(element);
                }
                namespaces.configure(namespaceAware);
            }
            injectNamespaces(childElement, binder);
        }
    }
}
Also used : Namespaces(org.apache.camel.builder.xml.Namespaces) NamespaceAware(org.apache.camel.spi.NamespaceAware) NodeList(org.w3c.dom.NodeList) ExpressionNode(org.apache.camel.model.ExpressionNode) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) Endpoint(org.apache.camel.Endpoint)

Example 2 with Namespaces

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

the class XQueryHeaderNameResultTypeAndNamespaceTest method createRouteBuilder.

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

        public void configure() throws Exception {
            Namespaces ns = new Namespaces("c", "http://acme.com/cheese");
            from("direct:in").choice().when().xquery("/c:number = 55", Integer.class, ns, "cheeseDetails").to("mock:55").otherwise().to("mock:other").end();
        }
    };
}
Also used : Namespaces(org.apache.camel.builder.xml.Namespaces) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 3 with Namespaces

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

the class XQueryWithNamespacesFilterTest 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().xquery("/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 4 with Namespaces

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

the class RssToHttpIssueTest method createRouteBuilder.

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

        @Override
        public void configure() throws Exception {
            Namespaces ns = new Namespaces("atom", "http://www.w3.org/2005/Atom");
            from("rss:http://www.plosone.org/article/feed").marshal().rss().setHeader(Exchange.HTTP_URI).xpath("//atom:entry/atom:link[@type=\"application/pdf\"]/@href", ns).to("http://dummy").to("mock:end");
        }
    };
}
Also used : Namespaces(org.apache.camel.builder.xml.Namespaces) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 5 with Namespaces

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

the class CamelNamespaceHandler method injectNamespaces.

protected void injectNamespaces(Element element, Binder<Node> binder) {
    NodeList list = element.getChildNodes();
    Namespaces namespaces = null;
    int size = list.getLength();
    for (int i = 0; i < size; i++) {
        Node child = list.item(i);
        if (child instanceof Element) {
            Element childElement = (Element) child;
            Object object = binder.getJAXBNode(child);
            if (object instanceof NamespaceAware) {
                NamespaceAware namespaceAware = (NamespaceAware) object;
                if (namespaces == null) {
                    namespaces = new Namespaces(element);
                }
                namespaces.configure(namespaceAware);
            }
            injectNamespaces(childElement, binder);
        }
    }
}
Also used : Namespaces(org.apache.camel.builder.xml.Namespaces) NamespaceAware(org.apache.camel.spi.NamespaceAware) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element)

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