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

Re: Is this possible in xsl ?

Subject: Re: Is this possible in xsl ?
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 10 Aug 2001 16:16:28 +0100
cap xsl
Hi Anne,

> So the data is in the xml sorted in the capfiles with the info to
> which cap it belongs, but in the html I want it to sort by organism.
> Is this possible? I tried to do it with <xsl:for-each
> select="//organism"> but it doesn't work at all, all the organsims
> are repeated.

This looks like a grouping problem. You want to group the data by the
organisms that they're under. You need to create a key that indexes
the data elements by the org:

<xsl:key name="data-by-org" match="data" use="org" />

Then you can retrieve all the data elements for Organism1 with:

  key('data-by-org', 'Organism1')

You can find the names of all the organisms by going through all the
data elements in your document and finding those that are the first
data elements returned by the key for their particular value, with:

  <xsl:for-each select="//data[count(.|key('data-by-org', org)[1]) =
                               1]">
    <xsl:value-of select="org" />
    ...
  </xsl:for-each>

I'm not exactly sure what you want to do with the data elements, but
it looks like you might want to iterate over them and give some kind
of output based on the number of cap ancestors they have, so something
like:

  <xsl:for-each select="//data[count(.|key('data-by-org', org)[1]) =
                               1]">
    <xsl:value-of select="org" />
    <xsl:for-each select="key('data-by-org', org)">
      <br />
      <xsl:for-each select="ancestor::cap">
        <xsl:text>cap</xsl:text>
        <br />
      </xsl:for-each>
      <xsl:value-of select="info" /><br />
    </xsl:for-each>
    <br /><br />
  </xsl:for-each>

For more detail on the theory, have a look at
http://www.jenitennison.com/xslt/grouping/muenchian.html.

I hope that gets you started,

Jeni

---
Jeni Tennison
http://www.jenitennison.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.