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

key grouping with non-existing or empty elements

Subject: key grouping with non-existing or empty elements
From: Xiaocun Xu <xiaocunxu@xxxxxxxxx>
Date: Tue, 24 Dec 2002 13:02:26 -0800 (PST)
key grouping
Hi,

	I have a question regarding grouping with key. 
Following is the input XML example:

<row row="1">
	<cell column="1">default_item1</cell>
	<cell column="6"></cell>
</row>
<row row="2">
	<cell column="1">default_item2</cell>
</row>
<row row="3">
	<cell column="1">lot01_item1</cell>
	<cell column="6">lot01</cell>
</row>
<row row="4">
	<cell column="1">lot02_item2</cell>
	<cell column="6">lot02</cell>
</row>

I have a number of items that need to be grouped by
lot (cell[column=6]).  As you can see, this cell is
optional.
I need to group rows that does not have cell[6] and
rows have cell[6] as empty string into the same group,
then process each of the row within the group via:
<xsl:apply-templates select="key('lineitemLotsKey',
$lotName)" mode="LineItem"/>

	The way I currently handling this is not very
elegent:
1. create a key on lot (cell 6) for all rows with cell
6 element:
	<xsl:variable name="LineItemLotColumn" select="6"/>
	<xsl:key name="lineitemLotsKey" match="//row[@row
&gt; $LineItemHeaderRow and
(cell[@column=$LineItemLotColumn])]"
use="cell[@column=$LineItemLotColumn]"/>
2. create a separate variable that contains rows that
does not have cell 6 element:
	<xsl:variable name="LineItemDefaultLot"
select="//row[@row &gt; $LineItemHeaderRow and
not(cell[@column=$LineItemLotColumn])]"/>
3. process $LineItemDefaultLot separately.
4. when process rows in key lineitemLotsKey, check for
string(cell[6]).  If empty, then does similar
processing as #3.

Of course, a slight improvement would be for #2,
instead of get all rows that does not have cell 6
element, also get all rows that has cell 6 element
equal to empty string.  That way, I would not need to
check for string(cell[6]) in step #4.

Is there a more elegent way than these above?

Thanks,

Xiaocun
xiaocunxu@xxxxxxxxx


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.