xmltools icon indicating copy to clipboard operation
xmltools copied to clipboard

Default namespace on XPath evaluation

Open morbac opened this issue 2 years ago • 3 comments

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

morbac avatar Apr 05 '22 18:04 morbac

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: image

There is certainly somthing I can do to make things easier. I'll put that issue in my todolist ;-)

morbac avatar Apr 05 '22 18:04 morbac

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.

mimccu avatar Apr 05 '22 20:04 mimccu

The same error in XSL Transformation option if the xsl have:

<xsl:stylesheet version="2.0" xpath-default-namespace="http://...."

The transformation will fails

bozoh avatar Jul 15 '22 00:07 bozoh