Subject: Re: [xsl] Fwd: Built-in *@ vs. node() From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Wed, 16 Oct 2002 16:22:53 +0100 |
Hi Janning, > In my XML Book "In a nutshell" it says: > "node() matches all nodes regardless of type: attribute, > namespace..." It's true that the *node test* node() matches all nodes regardless of type. However, a node test never exists alone -- it's always used alongside an *axis*, for example: child::node() attribute::node() The pattern "node()" is a shorthand for: child::node() which matches all nodes *that are children of some other node*. Attributes are not children of any node, therefore this pattern doesn't match attributes. If you want to match attributes, you have to use the attribute axis, e.g.: attribute::node() or: attribute::* or their shorthands: @node() @* So the identity template is usually written: <xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> i.e. match all nodes-that-are-children and all attributes, copy them, and go on to process their attributes or children, if they have any. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Fwd: Built-in *@ vs. node(), Janning Vygen | Thread | Re: [xsl] Fwd: Built-in *@ vs. node, Joerg Heinicke |
RE: [xsl] Fwd: Built-in *@ vs. node, Jarno . Elovirta | Date | Re: [xsl] Fwd: Built-in *@ vs. node, Joerg Heinicke |
Month |