[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: recursion with xsl:apply-templates

Subject: RE: recursion with xsl:apply-templates
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Wed, 27 Aug 2003 12:32:19 +0100
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.