I am writing an XSL transformation. I want to write a template which matches all the child elements of the document except one particular node. My xml looks like this -
<Document>
<NodeA></NodeA>
<NodeB></NodeB>
<ServiceNode></ServiceNode>
<NodeX></NodeX>
</Document>
I want to write a template that matches all nodes except ServiceNode
i.e. NodeA
to NodeX
. How to write this Xpath to get -
<xsl:template match="ALL Nodex Except ServiceNode">
If by "node" you mean element, then use:
If by "node" you mean any node (of type element, text, comment, processing-instruction): use
If you want only children of
Document
to be matched use:If you want only children of the top element to be matched use:
(or
local-name()
if you have to deal with namespaces)You could use two templates:
The later template will take priority, so the first template will match everything except ServiceNode.
You should better use this expression:
As incorporated in an XSLT:
With this XML sample:
It will give a correct result: