|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Identifier attribute (was: Re: Creating Hie
> How would I generate these id/sequence values, either as a
> second pass, or as part of the first pass which generates
> this structure from the non-hierarchical source file?
> <root>
> <a id="1">
> <b id="2">
> <e/>
> </b>
> <b id="3">
> <c id="4"/>
> </b>
I think the only way to do this is in a second pass. It then becomes fairly
easy:
Assuming you give the elements a blank id attribute in the first pass
(id=""), then in the second pass do
<xsl:template match="*[@id]" mode="pass2">
<xsl:copy>
<xsl:attribute name="id">
<xsl:number level="any" count="*[@id]"/>
</xsl:attribute>
<xsl:apply-templates mode="pass2"/>
</xsl:copy>
</xsl:template>
plus an identity template.
Michael Kay
http://www.saxonica.com/
|
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
|

Cart








