|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: combining the children of similar nodes under one
> -----Original Message-----
> From: David Montalvo
>
<snip />
> One of the problems is that <style> and <type> are being used
> interchangeably, but I think I compensated for that. My big problem is
> getting everything listed under one name with no duplicates.
>
Hi,
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>
Hope this helps!
Cheers,
Andreas
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








