[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
> 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/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|