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

RE: WG: Display attribute inside an xsl:for-each-group

Subject: RE: WG: Display attribute inside an xsl:for-each-group loop
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 23 Jun 2005 08:36:39 +0100
display attribute
> Line 4 is of special interest - thats where the contents should :) be
> displayed. While <xsl:value-of select="text()" /> works fine,
> <xsl:value-of select="@myattr/text()" /> produces an error in the
> XSL-parser:
>  
> Warning: on line 65 of
> file:/srv/www/htdocs/bka/./tmp/evaluations/42ba56a40e38d.xsl: 
> The child
> axis starting at an attribute() node will never select anything
>  

And I thought that error message was so helpful!

To display the value of attribute @att, do <xsl:value-of select="@att"/>.
The message is telling you that @att/text() doesn't make much sense: it's
short for attribute::att/child::text(), and attribute nodes don't have
children so this will always be an empty set.

(There are some object models in which attribute nodes do own text nodes;
but that's not the case in the XPath model).

To display the element, it's better to do <xsl:value-of select="."/> than
<xsl:value-of select="text()"/>. That's because an element may own several
text nodes, separated by comments or processing instructions. XSLT 2.0 will
give you the space-separated concatenation of the text nodes, but 1.0 will
give you the first one and ignore the others.

Michael Kay
http://www.saxonica.com/

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.