Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Recursive substitution

From: Agnisys <agnisys@--------->
To:
Date: 11/3/2005 10:21:00 PM
To illustrate what I mean by "stiching" please see the example below. When node DEF2 is
referenced, the new tree is processed as if the node existed there. So all the axis are modified
accordingly. Thats the reason I had to use "copy-of".

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:
Register: REG4 Prev-sibling: 
Register: REG3 Prev-sibling: REG4
Register: REG2 Prev-sibling: REG3
Register: REG1 Prev-sibling: REG2

Thanks for your help.
Anupam.

--- David Carlisle <davidc@xxxxxxxxx> wrote:

> 
> > Unfortunately my problem is that I did want to use a "copy-of" so that the nodes being
> referred to
> > by the <ref> tag are actually "stitched" into the tree.
> 
> I have no idea what you mean by stiched here. The code I posed roduced
> the output you saod you needed, if in fact you need different output I
> suggest that you repost with a different sample result.
> 
> I applied templates to the refereneced nodes.
> 
> > <xsl:template match="ref">
> >  <xsl:apply-templates select="key('r',@name)"/>
> > </xsl:template>
> 
> 
> You generate a new tree in memory that consist just of a document node
> with child the referenced nodes, and then apply templates to that.
> 
>     <xsl:template match="ref[@name]"> 
>         <xsl:variable name="x">
>             <xsl:copy-of select="key('r',@name)"/>
>         </xsl:variable>
>         <xsl:apply-templates select="$x"/>
>     </xsl:template>
> 
> This takes mre memory, because of the copy but will produce the smae
> result unless your have a template matching / that does something other
> han the default action of applying templates to your children, or if the
> templates that match the referenced nodes use Xpath expressions to
> select their parsents or any other ancestor, as in my version they will
> have the parents they had in the original tree, but in your version the
> tree only has these nodes,all with parent /
> 
> David
> 
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________
> 
> 



		
__________________________________ 
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