*
is used to match any element. Where you have square brackets, this represents a condition to be checked on that element. In this case not(*)
is checking that there are no child elements.
Therefore <xsl:template match="*[not(*)]">
will match elements that have no child elements. Thus it it would match this (as Bob
is a text node, not an element)
<Name>Bob</Name>
And this (as type
is an attribute, not an element).
<Name type="A" />
But it would not match this (as Name
has the child element FirstName
)
<Name><FirstName>Bob</FirstName></Name>
The second pattern <xsl:template match="*(*)">
is not actually valid syntax.
If you were trying to match elements which did have child elements, you would do this:
<xsl:template match="*[*]">