What we mean by this xsl notation <xsl:template match="/|@*|node()">

Ironman picture Ironman · Nov 16, 2012 · Viewed 25.6k times · Source

I dont understand what we mean by this..

<xsl:template match="/|@*|node()">
<xsl:apply-templates match="@*|node()"/>
</xsl:template>

Please help me out..

    <xsl:template match="local-name()='status'"/> 
<xsl:template match="/|@*|node()"> 
<xsl:copy> 
<xsl:apply-templates match="@*|node()"/> 
<xsl:copy> 
</xsl:template>

If i apply like this it is omitting the <status>node in my xml,howz it happening

Answer

Martin Honnen picture Martin Honnen · Nov 16, 2012

/|@*|node() is a match pattern composed of three single patterns. / matches a root node, also called document node, @* matches any attribute node and node() as a pattern "matches any node other than an attribute node and the root node". So for any kind of node (as those three patterns describe all types of nodes) the template says <xsl:apply-templates select="@*|node()"/> which means process the union of the attribute nodes and the child nodes. Document nodes matched by / don't have attribute nodes and attributes don't have them either but as a compact way you often see templates like that.

However there is a built-in template for document nodes that does <xsl:template match="/"><xsl:apply-templates/></xsl:template> so usually people omit the / in the pattern.