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

group-by an optional attribute

Subject: group-by an optional attribute
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Tue, 22 Nov 2011 10:12:41 -0700
 group-by an optional attribute
Hi,
Consider:
<xsl:for-each-group select="current-group()" group-by="Stamp/@line"

This fails because @line is an optional attribute and does not always appear in the XML. The only cure I can think of is to run a pre-processing stylesheet that, should the @line attribute be absent from a <Stamp> element, adds an @line="0" to each <Stamp> element. This is not a problem, but I wondered if there were another more elegant means making the group-by work?

I tried to formulate an alternative, thinking this would group-by the true value of @line were it present, or by zero in its absence, but it fails:
<xsl:for-each-group select="current-group()" group-by="if(Stamp/@line) then Stamp/@line else 0">


Thanks for any help,
Mark

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.