Mike,

I don't think leading/trailing whitespace is significant in a URI, so
I guess we could strip those in our NameSpaceContext implementation so
you can have the pretty-print XML syntax and have a working SU at the
same time.  Could you open a JIRA issue for that?  Feel free to add a
patch btw ;)

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/5/18 Mike Wagner <[email protected]>:
>
> Found the problem. When I hit Ctrl-Shift-F in Eclipse to format my XML in my
> xbean.xml file, the following whitespace was introduced and drools didn't
> interpret my namespace context correctly. So much for trying to keep my XML
> pretty. >-(
>
> From:
>  <drools:namespace-context id="nxContext">
>    <drools:namespaces>
>      <drools:namespace prefix="my">urn:my:ns</drools:namespace>
>    </drools:namespaces>
>  </drools:namespace-context>
>
> To:
>  <drools:namespace-context id="nxContext">
>    <drools:namespaces>
>      <drools:namespace prefix="my">
>         urn:my:ns
>      </drools:namespace>
>    </drools:namespaces>
>  </drools:namespace-context>
>
>
>
>
> Mike Wagner wrote:
>>
>> Still having problems with servicemix-drools and namespaces.
>>
>> I am passing in the namespace context with the following:
>>
>>   <drools:namespace-context id="nxContext">
>>     <drools:namespaces>
>>       <drools:namespace prefix="my">urn:my:ns</drools:namespace>
>>     </drools:namespaces>
>>   </drools:namespace-context>
>>
>> When my rules file tries to use xpath as follows
>>
>>   eval( in.xpath("/my:invoice/item/quantity > 10"))
>>
>> I get the following error:
>>
>>   TransformerException: Extra illegal tokens: 'urn:my:ns', ':', 'invoice'
>>
>>
>> Any ideas would be appreciated.
>>
>> Thanks,
>> Mike
>>
>>
>> Mike Wagner wrote:
>>>
>>> Should have been ServiceMix version 3.3.1.17
>>>
>>>
>>> Mike Wagner wrote:
>>>>
>>>> Trying to use namespaces in xpath expressions within servicemix-drools
>>>> doesn't seem to recognize the namespaces. I saw a bug fix was made for
>>>> this in 3.1 but still doesn't seem to work for me.
>>>>
>>>> for example XML:
>>>>
>>>> <invoice xmlns="urn:my:ns">
>>>>   <item>
>>>>     <name>Pen</name>
>>>>     <quantity>10</quantity>
>>>>   </item>
>>>>   <item>
>>>>     <name>Paper</name>
>>>>     <quantity>100</quantity>
>>>>   </item>
>>>> </invoice>
>>>>
>>>>
>>>> Drools file
>>>> router.drl
>>>>
>>>> rule test
>>>>      when
>>>>             $me : Exchange(status == Exchange.ACTIVE, $in : in != null)
>>>>
>>>> eval($in.xpath("/invoice[namespace-uri='urn:my:ns']/item[1]/quantity >
>>>> 5")
>>>>      then
>>>> ...
>>>>
>>>>
>>>> this evaluation returns false, but if I remove the namespace from the
>>>> XML and replace the eval with the following it returns true, as
>>>> expected.
>>>>
>>>> eval($in.xpath("/invoice/item[1]/quantity > 5")
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/Xpath-with-Namespaces-in-servicemix-drools-SMX-v3.3.17-tp23565332p23600155.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>

Reply via email to