[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: Re: Re: Unbounded element grouping/concatenati

Subject: Re: Re: Re: Re: Unbounded element grouping/concatenation
From: "Gupta, Raman K [CI]" <raman.k.gupta@xxxxxxxxxxxxx>
Date: Fri, 12 Dec 2003 15:32:54 -0500
gupta k templates
Dimitre,

One change to your algorithm... the xsl:choose inside the record 
match is not required because the continuation records are copied
when each header record is selected. Slightly simpler and I don't
think I broke anything (gives me the same result for my test
case anyway). Here is the new version:


<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 >

  <xsl:output omit-xml-declaration="yes" indent="yes"/>

  <xsl:variable name="vposArray">
    <xsl:value-of select="'|'"/>
    <xsl:for-each select="/*/record">
      <xsl:if test="@type = 'normal'">
        <xsl:value-of select="concat(position(), '|')"/>
      </xsl:if>
    </xsl:for-each>
  </xsl:variable>

  <xsl:template match="@* | node()" name="identity">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="records">
    <records>
      <xsl:apply-templates select="record"/>
    </records>
  </xsl:template>

  <xsl:template match="record">
    <xsl:variable name="vPos" select="position()"/>
    <xsl:variable name="vposNext"
      select="substring-before(
                      substring-after($vposArray,
                                      concat('|',
                                             position(),
                                             '|'
                                             )
                                      ),
                      '|'
                            )"/>
     <xsl:variable name="vNumNested"
       select="$vposNext - position() - 1"/>
     <xsl:copy>
       <xsl:copy-of select="@* | node()"/>
       <xsl:if test="$vNumNested > 0">
         <xsl:copy-of select=
           "following-sibling::record
                       [position() &lt;= $vNumNested]"/>
       </xsl:if>
     </xsl:copy>
  </xsl:template>

  <xsl:template match="record[not(@type='normal')]"/>
</xsl:stylesheet>

Cheers,
Raman Gupta

 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.