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

RE: repeating elements

Subject: RE: repeating elements
From: "WATKIN-JONES,ADAM (HP-UnitedKingdom,ex1)" <adam_watkin-jones@xxxxxx>
Date: Tue, 26 Mar 2002 13:58:37 -0000
xsl repeating elements
How about

    <xsl:template match="cell">
        <cell>
            <xsl:copy-of select="*"/>
            <xsl:copy-of select="*"/>
        </cell>
    </xsl:template>

if you wish to copy only twice or some fixed number of times.


Something like (hmmm, must get more creative with the language)

    <xsl:template match="cell">
        <cell>
            <xsl:call-template name="NCopy">
                <xsl:with-param name="nCount" select="3"/>
            </xsl:call-template>
        </cell>
    </xsl:template>

    <xsl:template name="NCopy">

        <xsl:param name="nCount"/>

        <xsl:copy-of select="*"/>

        <xsl:if test="$nCount > 1">
            <xsl:call-template name="NCopy">
                <xsl:with-param name="nCount" select="$nCount - 1"/>
            </xsl:call-template>
        </xsl:if>

    </xsl:template>

if you need to vary the number of copies between 1 and x.


-----Original Message-----
From: Joeri Belis

How can i copy everything between the <cell> tag more than once?

<?xml version="1.0"?>
<row>
  <cell>
    <data atr="1">9</data>
    <namedcell name="A"/>
    <data atr="2">9</data>
    <namedcell name="B"/>
  </cell>
</row>

Should become:

<?xml version="1.0"?>
<row>
  <cell>
    <data atr="1">9</data>
    <namedcell name="A"/>
    <data atr="2">9</data>
    <namedcell name="B"/>
    <data atr="1">9</data>
    <namedcell name="A"/>
    <data atr="2">9</data>
    <namedcell name="B"/>
  </cell>
</row>



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

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


Current Thread
  • repeating elements
    • Joeri Belis - Tue, 26 Mar 2002 08:19:47 -0500 (EST)
      • cutlass - Tue, 26 Mar 2002 08:38:23 -0500 (EST)
      • Michael Kay - Tue, 26 Mar 2002 09:17:01 -0500 (EST)
      • <Possible follow-ups>
      • WATKIN-JONES,ADAM (HP-UnitedKingdom,ex1) - Tue, 26 Mar 2002 08:54:05 -0500 (EST) <=

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.