Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Recursive substitution

From: Agnisys <agnisys@--------->
To:
Date: 11/1/2005 10:05:00 PM
Hi,
 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>
    
    <define name="DEF2">
        <reg name="REG2"/>
        <ref name="DEF1"/>
    </define>
  
     <block name="block1">
          <reg name="REG3"/>
          <ref name="DEF2"/>
     </block>

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

-------------------------------

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?

Thanks,
Anupam.
 


		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent