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

Copying Node Multiple Time

Subject: Copying Node Multiple Time
From: amarjit.s.bhullar@xxxxxxxxxxxxx
Date: Wed, 4 Apr 2001 16:58:10 -0400
supplierpartauxiliaryid
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


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.