Skip to content

Instantly share code, notes, and snippets.

@pegli
Created May 27, 2011 22:31
Show Gist options
  • Save pegli/996326 to your computer and use it in GitHub Desktop.
Save pegli/996326 to your computer and use it in GitHub Desktop.
XPath namespace declaration and routeContext
<!-- xpathFilterWithNamespace.xml from existing camel-spring test case; works fine -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo="http://example.com/person"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
">
<!-- START SNIPPET: example -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<filter>
<xpath>/foo:person[@name='James']</xpath>
<to uri="mock:result"/>
</filter>
</route>
</camelContext>
<!-- END SNIPPET: example -->
</beans>
<!-- xpathFilterWithNamespaceOnRouteContext.xml created from above, fails -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo="http://example.com/person"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
">
<routeContext id="myCoolRoutes" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<filter>
<xpath>/foo:person[@name='James']</xpath>
<to uri="mock:result"/>
</filter>
</route>
</routeContext>
<!-- START SNIPPET: example -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<routeContextRef ref="myCoolRoutes"/>
</camelContext>
<!-- END SNIPPET: example -->
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment