[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Sub group grouping using generate-id
Subject: RE: [xsl] Sub group grouping using generate-id From: Américo Albuquerque <melinor@xxxxxxx> Date: Sat, 16 Aug 2003 02:33:55 +0100 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Sub group grouping using gene, Wiepert, Mathieu | Thread | [xsl] Replacing words in an element, Joseph Tan |
[xsl] include problem, Kevin Waterson | Date | RE: [xsl] include problem, Lars Huttar |
Month |
Keywords