xsl-list
[Top] [All Lists]

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

2005-06-23 00:36:39
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/



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>