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]

Copying Node Multiple Time


I have the following XML document.

<Cart>
      <ItemIn quantity="2"  lineNumber="1">
         <ItemID>
                <SupplierPartID>1030</SupplierPartID>

<SupplierPartAuxiliaryID>289,472967,3,,,,,</SupplierPartAuxiliaryID>
         </ItemID>
      </ItemIn>
</Cart>

The output would look as follows

    <NewCart>
      <ItemIn quantity="1"  lineNumber="1">
         <ItemID>
                <SupplierPartID>1030</SupplierPartID>

<SupplierPartAuxiliaryID>289,472967,3,,,,,</SupplierPartAuxiliaryID>
         </ItemID>
      </ItemIn>
      <ItemIn quantity="1"  lineNumber="2">
         <ItemID>
                <SupplierPartID>1030</SupplierPartID>

<SupplierPartAuxiliaryID>289,472967,3,,,,,</SupplierPartAuxiliaryID>
         </ItemID>
      </ItemIn>
    </NewCart>

I would like to use the quantity attribute to create multiple copies of the
ItemIn node and set the quantity attribute to 1 and increment the line
number.
I have started with the following XSL code and would like to know how to
create a loop to do multiple copies.

<?xml version="1.0"?>
 <xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform";>
 <xsl:template match="/">
    <NewCart>
         <xsl:for-each select="//ItemID">
              <xsl:sort select
="substring-before(SupplierPartAuxiliaryID,',')" data-type="number"/>
              <xsl:sort select="SupplierPartID" data-type="number"/>
                  <xsl:copy-of select="parent::node()"/>
         </xsl:for-each>
    </NewCart>
</xsl:template>
</xsl:stylesheet>

Any help would be appreciated.
Thanks
Amarjit


 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]