|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Grouping with keys or xpath
At 2002-10-04 12:11 +0200, Ulf Carlsson wrote:
I only want to group each articlerow in one variant at time. When I need to do this, I use variables instead of key tables, since variables collect only those nodes to be grouped. Any hint/help would be appreciated A solution is below. Note in the algorithm that only the nodes in the collection being grouped are examined for uniqueness and revisited for detail. When not needing a node set of the unique members, this technique is very useful. I hope this helps. .................... Ken
T:\ftemp>type ulf.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:output indent="yes"/> <xsl:template match="doc">
<document>
<partinfo>
<xsl:for-each select="variant">
<partlist>
<xsl:variable name="articlerows" select="articlerow"/>
<xsl:for-each select="$articlerows | parttitle">
<xsl:if test="self::parttitle">
<title><xsl:value-of select="."/></title>
</xsl:if>
<xsl:if test="generate-id(.)=
generate-id($articlerows[nev_article_pos=
current()/nev_article_pos])">
<partcallout>
<calloutitem>
<xsl:value-of select="nev_article_pos"/>
<xsl:for-each select="$articlerows[nev_article_pos=
current()/nev_article_pos]">
<article>
<xsl:value-of select="article/nev_article"/>
</article>
</xsl:for-each>
</calloutitem>
</partcallout>
</xsl:if>
</xsl:for-each>
</partlist>
</xsl:for-each>
</partinfo>
</document>
</xsl:template></xsl:stylesheet> T:\ftemp>xt ulf.xml ulf.xsl ulf.out T:\ftemp>type ulf.out <?xml version="1.0" encoding="utf-8"?> <document> <partinfo> <partlist> <partcallout> <calloutitem>1<article>009504145</article> </calloutitem> </partcallout> <partcallout> <calloutitem>12<article>009504145</article> <article>009504145</article> </calloutitem> </partcallout> <title>Hello World</title> <partcallout> <calloutitem>18<article>009504145</article> </calloutitem> </partcallout> <partcallout> <calloutitem>19<article>009504145</article> <article>009504145</article> </calloutitem> </partcallout> </partlist> <partlist> <partcallout> <calloutitem>4<article>009504145</article> <article>009504145</article> </calloutitem> </partcallout> <title>Hello World</title> <partcallout> <calloutitem>6<article>009504145</article> </calloutitem> </partcallout> <partcallout> <calloutitem>18<article>009504145</article> </calloutitem> </partcallout> <partcallout> <calloutitem>19<article>009504145</article> <article>009504145</article> </calloutitem> </partcallout> </partlist> </partinfo> </document> T:\ftemp>rem Done!
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
|

Cart








