[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: Fri, 4 Nov 2005 11:55:14 -0800 (PST)
recursive substitution
I've reformatted my question:

 Input XML:
 <x>
     <define name="DEF1">
         <reg name="REG1"/>
     </define>
     
     <define name="DEF2">
         <reg name="REG2"/>
         <ref name="DEF1"/>
     </define>
      
     <block name="block1">
         <reg name="REG4"/>
         <reg name="REG3"/>
         <ref name="DEF2"/>
     </block>
 </x>
----------------------
Output Expected XML:
 
     <block name="block1">
         <reg name="REG4"/>
         <reg name="REG3"/>
         <reg name="REG2"/>
         <reg name="REG1"/>
     </block>
----------------------
But when I apply the following stylesheet I get the following: (Note the missing REG1 node)

     <block name="block1">
         <reg name="REG4"/>
         <reg name="REG3"/>
         <reg name="REG2"/>
     </block>

----------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="*" >
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates/>
        </xsl:copy>
</xsl:template>

<xsl:template match="ref[@name]"> 
        <xsl:variable name="x">
            <xsl:copy-of select="//define[@name=current()/@name]/*"/>
        </xsl:variable>
        <xsl:apply-templates select="$x"/>
</xsl:template> 
    
<xsl:template match="/*/define"/>
</xsl:stylesheet>


Thanks,
Anupam.




	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.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

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.