[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

Subject: Re: combining the children of similar nodes under one node
From: David Montalvo <damontal@xxxxxxxxxxx>
Date: Sun, 7 Mar 2004 12:43:34 -0500
david montalvo
Thanks Andreas. I'll give it a try. Is that method you suggested known as the Meunchian method? I remember reading about it somewhere...
dave


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>


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.