text()" vs. "node()"

[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: "*|@*|text()" vs. "node()"

Subject: Re: "*|@*|text()" vs. "node()"
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Thu, 04 Oct 2001 14:44:15 +0100
Re:  "*|@*|text()" vs. "node()"
Hi Jörg,

Jörg Heinicke wrote:
> 
> I want to shorten/improve my XSL-code, but a problem occures. Until now I
> had a stylesheet like the following:
> 
> <xsl:template match="*|@*|text()">
>    <xsl:copy>
>      <xsl:apply-templates select="*|@*|text()"/>
>    </xsl:copy>
> </xsl:template>
> 
Take a look at the XSLT spec for the "identity transform"
(http://www.w3.org/TR/xslt.html#copying). Their identity transform uses 

	<xsl:template match="@*|node()">

Then look under patterns and you find the XSLT definition of the node()
test:

	node() matches any node other than an attribute node and the root node

which is slightly confusing since the XPath spec defines it as:

	A node test node() is true for any node of any type whatsoever.

So then maybe it isn't the match that's wrong, maybe it's the select -
so look under attribute in XPath
(http://www.w3.org/TR/1999/REC-xpath-19991116#attribute-nodes)

	Each element node has an associated set of attribute nodes; the element
is the parent of each of these attribute nodes; however, an attribute
node is not a child of its parent element.

So <xsl:apply-templates select="node()"/> is short for
<xsl:apply-templates select="child::node()"/>, and attributes aren't on
the child axis of their parent element.

So you should be able to re-write the XSLT identity transform as 

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

but that *doesn't* work - it drops attributes - so I guess the XSLT
definition of node() applies rather than the XPath one.

Francis.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.