RE: [xsl] howto add elements to sections of xml document

Subject: RE: [xsl] howto add elements to sections of xml document
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Mon, 8 Mar 2004 18:14:03 +0100
> -----Original Message-----
> From: John Mason
>
> I would like to tranform the following xml:


Hi,

Try something like:

<xsl:stylesheet ..>
...
<xsl:key name="para-by-title" match="para" use="preceding-sibling::title[1]"
/>

<xsl:template match="doc">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="section">
  <xsl:copy>
    <xsl:apply-templates select="title" />
  </xsl:copy>
</xsl:template>

<xsl:template match="title">
  <sub-section>
    <xsl:copy-of select="." />
    <xsl:copy-of select="key('para-by-title',.)" />
  </sub-section>
</xsl:template>


Hope this helps!

Cheers,

Andreas


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


Current Thread