Subject: Re: [xsl] combining the children of similar nodes under one node From: David Montalvo <damontal@xxxxxxxxxxx> Date: Sun, 7 Mar 2004 12:43:34 -0500 |
Sounds like a grouping-problem...
Try something like:
<xsl:stylesheet ...> <xsl:key name="prods-by-name" match="product" use="name" /> <xsl:key name="style-type-by-prod" match="style | type" use="concat(parent::product/name,.)" />
<xsl:variable name="distinct-prods" select="//product[generate-id(.)=generate-id( key('prods-by-name',name))]" />
<xsl:template match="root"> <xsl:apply-templates select="$distinct-prods" mode="merge"/> </xsl:template>
<xsl:template match="product" mode="merge">
<xsl:copy>
<xsl:copy-of select="name" />
<xsl:apply-templates select="key('prods-by-name',name)" mode="list" />
</xsl:copy>
</xsl:template>
<xsl:template match="product" mode="list">
<xsl:apply-templates select="(style | type)[generate-id(.)=generate-id(
key('style-type-by-prod',concat(
current()/name,.)))]" />
</xsl:template>
<xsl:template match="style | type"> <xsl:copy-of select="." /> </xsl:template>
</xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] combining the children of, Andreas L. Delmelle | Thread | RE: [xsl] combining the children of, Andreas L. Delmelle |
RE: [xsl] What is the best XSLT boo, Ragulf Pickaxe | Date | RE: [xsl] combining the children of, Jim Fuller |
Month |