|
Subject: [xsl] Recursive substitution From: Agnisys <agnisys@xxxxxxxxx> Date: Tue, 1 Nov 2005 14:04:49 -0800 (PST) |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Default namespace in XML , drkm | Thread | Re: [xsl] Recursive substitution, David Carlisle |
| Re: [xsl] Processing IDREFS attribu, Dan Vint | Date | Re: [xsl] Processing IDREFS attribu, David Carlisle |
| Month |