[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Identifier attribute (was: Re: Creating Hi
Ken,
Many thanks for your help - this is now working and I've got two-pass processing working on my full transform. Now I've got a further problem - the second pass is inserting the values in the id attributes, but it's dropping any other attributes that are in the result of pass1. It's nothing to do with the two-pass process since the same problem occurs if I run just the second pass. So I want to transform this: <newnode id="" x="539"> <name>Root of my tree</name> <newnode id="" x="267" y="tomjones"> <name>Child of root</name> </newnode> <newnode id=""> <name>Another child of root</name> <newnode id="" price="4.99"> <name>Grandchild of root</name> </newnode> </newnode> <newnode id=""> <name>Yet another child of root</name> </newnode> </newnode> into this: <newnode id="1" x="539"> <name>Root of my tree</name> <newnode id="2" x="267" y="tomjones"> <name>Child of root</name> </newnode> <newnode id="3"> <name>Another child of root</name> <newnode id="4" price="4.99"> <name>Grandchild of root</name> </newnode> </newnode> <newnode id="5"> <name>Yet another child of root</name> </newnode> </newnode> My transform is: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsl:output method="xml" indent="yes"/> <xsl:template match="*[@id]"> <xsl:copy> <xsl:attribute name="id"> <xsl:number level="any" count="*[@id]"/> </xsl:attribute> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> It adds the values to the id attributes but omits all the other attributes. What do I have to do to this to get it to copy all the attributes to the output file? I'm sure this is trivial, but everything I've tried has either had no effect or caused an error message. Thanks - Rowan
|
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
|