On Tue, Apr 24, 2012 at 5:11 PM, Bob Jolliffe <bobjolli...@gmail.com> wrote:
> On 24 April 2012 15:22, Claus Ibsen <claus.ib...@gmail.com> wrote:
>> Hi
>>
>> Thanks
>>
>> Just to be sure how do you refer to this external file?
>>
>
> I'm loading it with:
>
> FileInputStream is = new FileInputStream( file );
>
> try
> {
>     RoutesDefinition routes = camelContext.loadRoutesDefinition( is );
>     camelContext.addRouteDefinitions( routes.getRoutes() );
> }
> catch ( Exception e )
> {
>     log.info( "Unable to load route: " + e.getMessage() );
>     return ERROR;
> }
>

Ah okay, I don't think namespaces is injected into the xpath/xquery
predicates/expression when you do it like that.
This is done using JAXB which loads the model from the XML. It would
require a bit more effort to discover the custom namespace
declarations.




>>
>>
>>
>> On Mon, Apr 23, 2012 at 6:54 PM, Bob Jolliffe <bobjolli...@gmail.com> wrote:
>>> On 23 April 2012 17:29, Claus Ibsen <claus.ib...@gmail.com> wrote:
>>>> Hi
>>>>
>>>> Do you declare the route in an external file, or how do you refer to
>>>> the xml file with that route?
>>>> Maybe you can post your full XML files.
>>>
>>> I have the route declared in an external file.  The following is a
>>> complete listing of the file which illustrates the problem:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <route xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>>  xsi:schemaLocation="http://camel.apache.org/schema/spring
>>> camel-spring-2.9.1.xsd"
>>>  xmlns="http://camel.apache.org/schema/spring";
>>>  xmlns:d="http://dhis2.org/schema/dxf/2.0";
>>>  id="dataUpdater">
>>>
>>>  <description>Import Metadata</description>
>>>  <!-- every now and again ... -->
>>>  <from 
>>> uri="quartz://halfminute?trigger.repeatInterval=300000&amp;trigger.repeatCount=10"/>
>>>  <to
>>>       uri="http://localhost/trunk/api/metaData.xml"/>
>>>  <split>
>>>    <xpath>/d:dxf/d:organisationUnits/d:orgainsationUnit</xpath>
>>>    <log loggingLevel="INFO" message="Processed one orgunit" />
>>>  </split>
>>> </route>
>>>
>>> The error I get is:
>>> Failed delivery for (MessageId:
>>> ID-bobs-laptop-39546-1335131554800-0-25 on ExchangeId:
>>> ID-bobs-laptop-39546-1335131554800-0-24). Exhausted after delivery
>>> attempt: 1 caught:
>>> org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath:
>>> /d:dxf/d:organisationUnits/d:orgainsationUnit. Reason:
>>> javax.xml.xpath.XPathExpressionException (MarkerIgnoringBase.java
>>> [DefaultQuartzScheduler-camel-builtin_Worker-2])
>>>
>>> Note that I have declared xmlns:d="http://dhis2.org/schema/dxf/2.0"; on
>>> the route element.  It seems this is not being picked up.
>>>
>>> Regards
>>> Bob
>>>
>>>>
>>>>
>>>> On Mon, Apr 23, 2012 at 6:23 PM, Bob Jolliffe <bobjolli...@gmail.com> 
>>>> wrote:
>>>>> I have an application where I load a camel context using spring and
>>>>> then add different spring dsl routes particular to individual site
>>>>> configurations.
>>>>>
>>>>> I am having trouble using an XPath splitter because of the issue with
>>>>> making namespaces visible to the XPath processor.
>>>>>
>>>>> I've seen from here
>>>>> (http://camel.465427.n5.nabble.com/fail-filter-XPATH-camel-td476424.html)
>>>>> that if the route is defined within a camel context, then you can make
>>>>> the namespace visible in the usual way, as a xmlns declaration in the
>>>>> root (context) element.
>>>>>
>>>>> But this doesn't seem to work if I am loading just a route into an
>>>>> existing context.
>>>>>
>>>>> <route xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>>>>  xmlns="http://camel.apache.org/schema/spring";
>>>>>  xmlns:d="http://dhis2.org/schema/dxf/2.0";
>>>>>  id="dataUpdater">
>>>>>
>>>>>  <description>Import Metadata</description>
>>>>>  <!-- every now and again ... -->
>>>>>  <from 
>>>>> uri="quartz://halfminute?trigger.repeatInterval=300000&amp;trigger.repeatCount=10"/>
>>>>>  <to
>>>>>       uri="http://localhost/trunk/api/metaData.xml?"/>
>>>>>  <split>
>>>>>      <xpath>/d:/dxf2/d:organisationUnit</xpath>
>>>>>      <to .... />
>>>>>  </split>
>>>>>
>>>>> Camel complains that the xpath expression is illegal.  Has anyone come
>>>>> across (and maybe solved) this problem before?
>>>>>
>>>>> I've had a look at the tokenize xml approach, which seems nice (and
>>>>> efficient) but again it doesn't seem to handle namespaces.
>>>>>
>>>>> Any advice welcome.
>>>>>
>>>>> Regards
>>>>> Bob
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> -----------------
>>>> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
>>>> FuseSource
>>>> Email: cib...@fusesource.com
>>>> Web: http://fusesource.com
>>>> Twitter: davsclaus, fusenews
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
>> FuseSource
>> Email: cib...@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to