xmltools
xmltools copied to clipboard
Default namespace on XPath evaluation
On a separate note, can you tell me if this is a known issue under XML Tools? I have a FHIR Bundle that declares a default namespace at the top level. If I use evaluate XPath expression with the default namespace, it does not find any entries that match. However, if I remove the default namespace, evaluate XPath expression works. I tried to declare a default namespace under evaluate XPath expression but that didn't produce any better results. Here's an example:
- XPath expression: /Bundle/entry/resource/Organization/id/@value
- Example files with working (default namespace removed) and non-working (default namespace in use) example: CeQ_inactive_entries_simple_examples.zip
Thanks, Mike
Originally posted by @mimccu in https://github.com/morbac/xmltools/issues/154#issuecomment-1087572189
I agree with you that msxml xpath evaluation engine is almost unusable when having global namespace. Note that I'm not sure if this is caused by msxml or xpath 1.0...
Anyway, In order to evaluate xpath expression in your example you would have to define a named namespace in XPath Expression Evaluation dialog and prefix every node with that name. For instance:
There is certainly somthing I can do to make things easier. I'll put that issue in my todolist ;-)
Thanks @morbac . I was thinking of the same workaround but it's easier to just temporarily remove the default namespace declaration when possible.
Thanks in advance for any future efforts on this one.
The same error in XSL Transformation option if the xsl have:
<xsl:stylesheet version="2.0" xpath-default-namespace="http://...."
The transformation will fails