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

Sub group grouping using generate-id

Subject: Sub group grouping using generate-id
From: "Wiepert, Mathieu" <Wiepert.Mathieu@xxxxxxxx>
Date: Fri, 15 Aug 2003 16:01:48 -0500
wiepert
I have tried to simplify the problem, but still have difficulty getting my expected results.  Given this simplified xml doc,

<experiment>
  <genotypesInSubject>
    <id>1</id>
    <pcrResuts>
      <variant>
         <position>1</position>
      </variant>
      <variant>
         <position>2</position>
      </variant>
    </pcrResuts>
  </genotypesInSubject>
  <genotypesInSubject>
    <id>2</id>
    <pcrResuts>
      <variant>
         <position>1</position>
      </variant>
      <variant>
         <position>2</position>
      </variant>
      <variant>
         <position>3</position>
      </variant>
    </pcrResuts>
  </genotypesInSubject>
</experiment>
<experiment>
  <genotypesInSubject>
    <id>1</id>
    <pcrResuts>
      <variant>
         <position>1</position>
      </variant>
      <variant>
         <position>2</position>
      </variant>
      <variant>
         <position>4</position>
      </variant>
    </pcrResuts>
  </genotypesInSubject>
  <genotypesInSubject>
    <id>2</id>
    <pcrResuts>
      <variant>
         <position>1</position>
      </variant>
      <variant>
         <position>2</position>
      </variant>
      <variant>
         <position>3</position>
      </variant>
    </pcrResuts>
  </genotypesInSubject>
</experiment>

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"/>
	<xsl:key name="variant-key" match="//n1:variant" use="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])]"/>
		.
		.

Any hints would be appreciated,

thanks
-mat




 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.