[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Is this possible in 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|