Can anyone explain to me why the following xslt:
<xsl:if test="EventDocument">
Does not pickup this xml tag?
<EventDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.itron.com/ItronInternalXsd/1.0/">
it works when I delete the attributes from the tag, which makes no sense to me.
I.E. the above test passes when i modify the input to be:
<EventDocument>
I’m using xslt 2.0 (saxon parser) Thanks in advance
xmlnsis “reserved attribute” – it is definition of mapping of namespace prefix to full node namespace. Covered in details in What does "xmlns" in XML mean?I.e. actual name of the node in your case is
"http://www.itron.com/ItronInternalXsd/1.0/" EventDocument, but you trying to select"" EventDocument(Node with name “EventDocument” and empty namespace).Depending on your XPath engine you need either
*[namespace-uri()="http://www.itron.com/ItronInternalXsd/1.0/" and local-name()=="EventDocument"]*[local-name()=="EventDocument"](
local-nameandnamespace-uricovered in http://www.w3.org/TR/xpath/#section-Node-Set-Functions).