[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Recursively link XML blocks

Subject: Re: [xsl] Recursively link XML blocks
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 20 Nov 2001 10:15:03 +0000

Hi Costantino,

> In other words, I would like to "link" elements to other elements,
> and compose a new document "recursively".

When the processor comes across an insert element, it needs to get the
content of that insert element and find an element at the same level
as this one with that name, and apply templates to it. You can find an
element at the same level as this one with a particular name with:

  ../*[name() = $name]

So the template should look like:
<xsl:template match="insert">
  <xsl:variable name="name" select="." />
  <xsl:apply-templates select="../*[name() = $name]" />

If you apply templates directly to element_A to start off the process,
then you should get the output that you want:

  <xsl:apply-templates select="element_A" />

This relies on the default templates, such that when you apply
templates to element_A or element_B (and so on) the processor
automatically applies templates to their child text nodes and insert

I hope that helps,


Jeni Tennison

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread