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

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

Subject: WG: Display attribute inside an xsl:for-each-group loop
From: "Prerovsky, Clemens" <Clemens.Prerovsky@xxxxxxx>
Date: Thu, 23 Jun 2005 08:54:35 +0200
xsl display attribute
Hi guys,

I'm stuck (once again ;) with an XSL problem and I hope someone knows
how to solve it. I'm looping through my XML structure which looks like

<root>
    <sub_A>
        <node_A myattr="33533"/>
        <node_B>textual content</node_B>
        <node_B/>
        <node_C/>
        <node_D>textual content</node_D>
        <node_D myattr="1234567"/>
        <node_D/>
    </sub_A>
    <sub_B>
    ...
    </sub_B>
</root>

using a xsl:for-each-group loop because I want to display groups of node
names with a single header. The result should look like

node_A
33533
node_B
textual content
node_C
node_D
textual content
1234567

As you can see contents are stored inside a text node or an attribute
which is called "myattr". My loop construct looks like:

1    <xsl:for-each-group select="/root/sub_A/*"
group-adjacent="node-name()">
2        <xsl:value-of select="name()"/>
3        <xsl:for-each select="current-group()">
4            <xsl:value-of select="text()" /><xsl:value-of
select="@myattr/text()" />
5        </xsl:for-each>
6    </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

I'm using Saxon-B 8.0 working on a XSLT 2.0 stylesheet. Hope anybody can
figure this out.

Best regards - many thanks for your help!
Clemens Prerovsky

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.