what is the correct query to select the the “Abstract” Node which is implemented by XYZImpl from http://www.namspace.org/impl?
<...>
<Abstract xmlns:q3="http://www.namspace.org/impl"
xsi:type="q3:XYZImpl">
<...></...>
</Abstract>
<Abstract xmlns:q8="http://www.namspace.org/another"
xsi:type="q8:XYZImpl">
<...></...>
</Abstract>
</...>
order and namespace prefix are not under my control
If the document just contains unique implementations the following query “works”:
//Abstract[contains(@xsi:type,'XYZImpl')]
but I am searching for the right specification for the full qualified Name (namespace + Name)… :/
Use:
This selects any
Abstractchild of the top element of the XML document that has a namespace with a prefix, which is also the prefix of the QName value contained in itsxsi:typeattribute. And the “local-name” part of the QName value contained in thexsi:typeattribute is exactly the string"XYZImpl".XSLT – based verification:
When this transformation is applied on the following XML document (produced by the provide, by making it well-formed):
the wanted, correct element is selected and copied to the output:
Do note: In order for the XPath expression to be evaluated successfully, the appropriate namespace with prefix
xsimust be registered with your XPath implementation.