|
Subject: RE: [xsl] Identifier attribute (was: Re: [xsl] Creating Hierarchy) From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 20 Oct 2008 23:03:19 +0100 |
> 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/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Identifier attribute (was, Wendell Piez | Thread | Re: [xsl] Identifier attribute (was, Rowan Sylvester-Brad |
| Re: [xsl] Identifier attribute (was, Wendell Piez | Date | [xsl] Fwd: Parsing Excel - Selectin, Luciano Greiner |
| Month |