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

RE: Sub group grouping using generate-id

Subject: RE: Sub group grouping using generate-id
From: Américo Albuquerque <melinor@xxxxxxx>
Date: Sat, 16 Aug 2003 02:33:55 +0100
generate id key
Hi

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Wiepert, Mathieu
> Sent: Friday, August 15, 2003 10:02 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Sub group grouping using generate-id
> 
> 
> I have tried to simplify the problem, but still have 
> difficulty getting my expected results.  Given this 
> simplified xml doc,
> 
(...)
> 
> During processing, if I am at a given <experiment> node, how 
> do I get a variable holding unique variant nodes, as 
> classified by the <position> element?  Or put another way, 
> how do I get a list of <variant>'s unique to an <experiment> 
> node, using the <position> child element of <variant> as the key?
> 
> Expected results would be
> experiment node 1 has variant at position1,2, and 3
> experiment node 2 has variant at position 1,2,3, and 4
> 
> I have been trying to get this filled in but have been 
> spectacularly unsuccessful.
> 
> Here is one of the very many attempts...
> 
> <xsl:template match="/">
> 	<xsl:variable name="expNodes" select="//n1:experiment"/>

You probably don't need the '//' here. You can use select="[your root
node]/n1:experiment" instead

> 	<xsl:key name="variant-key" match="//n1:variant" 
> use="n1:position"/>
The xsl:key is a direct child of xsl:stylesheet, so this will give you an
error

This key will select a variant according to its child position, no matter
where it is
To select only those that belong to a certain experiment you'll have to had
that to the key
Something like:
<xsl:key name="variant-key" match="n1:variant"
use="concat(generate-id(ancestor::n1:experiment),n1:position)"/>

> 	.
> 	.
> 	<xsl:for-each select="$expNodes">
> 		<xsl:variable name="unique-exp-variants" 
>
select="//n1:variant[generate-id(//n1:position)=generate-id(key('variant-key
',.)[1])]"/>

This variable will never select anything. The key is matching n1:variant and
you are comparing it to n1:position, so, generate-id(n1:variant) will always
be different from generate-id(n1:position)
Your variable is also selecting all n1:variant of the document, you only
want those the are descendant of the current experiment. To select those you
can use descendant::n1:variant or, using its path,
n1:genotypesInSubject/n1:pcrResuts/n1:variant

The variable definition will be:
<xsl:variable name="unique-exp-variants"
select="n1:genotypesInSubject/n1:pcrResuts/n1:variant[generate-id()=generate
-id(key('variant',concat(generate-id(current()),n1:position)))]"/>

(...)

Regards,
Americo Albuquerque


 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.