This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]