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

Recursive substitution

Subject: Recursive substitution
From: Agnisys <agnisys@xxxxxxxxx>
Date: Tue, 1 Nov 2005 14:04:49 -0800 (PST)
xsl variable substitution
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

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.