[xsl] Recursive substitution

Subject: [xsl] Recursive substitution
From: Agnisys <agnisys@xxxxxxxxx>
Date: Tue, 1 Nov 2005 14:04:49 -0800 (PST)
 This problem is about how to create a recursive reference node and resolve it using XSL.

 My XML looks like this:

    <define name="DEF1">
        <reg name="REG1"/>
    <define name="DEF2">
        <reg name="REG2"/>
        <ref name="DEF1"/>
     <block name="block1">
          <reg name="REG3"/>
          <ref name="DEF2"/>

  The output I need is : 

Register : REG3

Register : REG2

Register : REG1

But I don't get the last line. In other words, the "ref" call is not resovling recursively.
My XSL looks like this :  

   <xsl:template match="/">
        <xsl:variable name="x">
            <xsl:apply-templates mode="pass1"/>
        <xsl:apply-templates mode="pass2" select="$x"/>
    <xsl:template match="*" mode="pass1">
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates mode="#current"/>
    <xsl:template match="define" mode="pass1">
    <xsl:template match="ref[@name]" mode="pass1">
        <xsl:variable name="x">
            <xsl:copy-of select="//define[@name=current()/@name]/*"/>
        <xsl:apply-templates select="$x" mode="#current"/>
    <xsl:template match="reg" mode="pass2">
        <br/>Register : <xsl:value-of select="@name"/><br/>


A follow up question is, in this kind of multi-pass processing, is there a way to dump out the
results after a pass to aid debug?


Yahoo! FareChase: Search multiple travel sites in one click.

Current Thread