|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Grouping with keys or xpath
Hello, I have achived to group my xml input(see further down) to the desired output (see further down) with with xsl file (see further down) using xpath, but I have not manage to do the same with keys and the key function. The problem is that the key is global for the whole document. I only want to group each articlerow in one variant at time. Any hint/help would be appreciated Best regards Uffe The xml file <doc> <variant> <articlerow> <nev_article_pos>1</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> <articlerow> <nev_article_pos>12</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> <articlerow> <nev_article_pos>12</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> <parttitle>Hello World</parttitle> <articlerow> <nev_article_pos>18</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> <articlerow> <nev_article_pos>19</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> <articlerow> <nev_article_pos>19</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> </variant> <variant> <articlerow> <nev_article_pos>4</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> <parttitle>Hello World</parttitle> <articlerow> <nev_article_pos>6</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> <articlerow> <nev_article_pos>4</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> <articlerow> <nev_article_pos>18</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> <articlerow> <nev_article_pos>19</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> <articlerow> <nev_article_pos>19</nev_article_pos> <article> <nev_article>009504145</nev_article> </article> </articlerow> </variant> </doc> The output <document> <partinfo> <partlist> <partcallout> <calloutitem>1</calloutitem> <article>009504145</article> </partcallout> <partcallout> <calloutitem>12</calloutitem> <article>009504145</article> <article>009504145</article> </partcallout> <title>Hello World</title> <partcallout> <calloutitem>18</calloutitem> <article>009504145</article> </partcallout> <partcallout> <calloutitem>19</calloutitem> <article>009504145</article> <article>009504145</article> </partcallout> </partlist> <partlist> <partcallout> <calloutitem>4</calloutitem> <article>009504145</article> <article>009504145</article> </partcallout> <title>Hello World</title> <partcallout> <calloutitem>6</calloutitem> <article>009504145</article> </partcallout> <partcallout> <calloutitem>18</calloutitem> <article>009504145</article> </partcallout> <partcallout> <calloutitem>19</calloutitem> <article>009504145</article> <article>009504145</article> </partcallout> </partlist> </partinfo> </document> The xsl file <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:nevis="http://www.volvo.com/namespaces/processing" xmlns:xlink = "http://www.w3.org/1999/xlink"> <xsl:strip-space elements="*"/> <xsl:template match="/doc"> <document> <partinfo> <xsl:apply-templates select="variant"/> </partinfo> </document> </xsl:template> <xsl:template match="variant"> <partlist> <xsl:apply-templates/> </partlist> </xsl:template> <xsl:template match="articlerow"> <xsl:for-each select="self::*[not(nev_article_pos = preceding-sibling::articlerow/nev_article_pos)]"> <partcallout> <calloutitem><xsl:value-of select="nev_article_pos"/></calloutitem> <xsl:apply-templates select="./..//article[current()/nev_article_pos =./../nev_article_pos]"/> </partcallout> </xsl:for-each> </xsl:template> <xsl:template match="parttitle"> <title> <xsl:value-of select="."/> </title> </xsl:template> <xsl:template match="article"> <article><xsl:value-of select="nev_article"/></article> </xsl:template> <xsl:template match="text()"/> </xsl:stylesheet> 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








