[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|