|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: recursion with xsl:apply-templates
> Anyway, my primary problem remains. Any ideas?
> Volker.
I would use a variable here, then query that for each id.
Something like:
<xsl:variable name="indexToIDs">
<xsl:for-each select="//*[@index]">
<xsl:variable name="pos" select="position()"/>
<entry genid="{generate-id()}"
id="{/transformation/id_list/id[$pos]}"/>
</xsl:for-each>
</xsl:variable>
Which will give you an RTF of elements like this:
<entry genid="abc" id="2003..."/>
<entry genid="foo" id="2004..."/>
Then you should perform an identity transform on your source, with an
extra template handling elements with @index.
In that template query the rtf (or more to the point, query a variable
that is a nodeset of the rtf) using the generated id of the current
element for its id, and construct your output how you want it, something
like:
The identity transform:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
The template to handle the special case:
<xsl:template match="*[@index]">
<xsl:variable name="genid" select="generate-id()"/>
<xsl:copy>
<xsl:copy-of select="$indexToIDsNodeSet/entry[@genid =
$genid]/@id"/>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
A template to supress @index
<xsl:template match="@index"/>
cheers
andrew
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
|

Cart








