0
votes

I am new to XSLT, when I saw few existing xslt files in my project I saw the following snippets,

  1. <xsl:apply-templates select="@*|node()" />
  2. <xsl:apply-templates select="@*|*" />

Could someone please explain what is difference between the above 2? Thanks, Kitty

1

1 Answers

3
votes

node() matches elements, text nodes, processing instructions and comments. So node() is the same as doing *|text()|processing-instruction()|comment()

* just matches elements

@* matches attributes

So, if you had the following XML

<Root Attribute="1">
  Text Node
  <Element>Text</Element>
</Root>

Then, assuming you were positioned on the Root node, if you did <xsl:apply-templates select="@*|node()" /> then it would select Attribute, Text Node and Element. But <xsl:apply-templates select="@*|*" /> would select only Attribute and Element.