xsl-list
[Top] [All Lists]

RE: Transforming XML to multiple different versions (multiple files)

2004-03-04 14:01:22
-----Original Message-----
From: Richard Corfield

<snip />

Hi,

I have worked out how to output the <chapter> elements to
multiple files, but I'm having trouble copy ing the preceding and
following parts of the xml. Here is a snippet of the XSL I have
been working with: (I'm using XML::LibXSLT to do the transform)


Since it appears that the relevant data is always in the same position
relative to the chapter elements, I'd guess something like this would do it

...
<!-- global -->
<xsl:variable name="vmeta" select="book/metadata" />
<xsl:variable name="vbook" select="book/bookdata/*[not(name(.)='contents')]"
/>
...
<xsl:template match="chapter">
  <xsl:document href="...">
    <book ref="ancestor::book/@id">
      <xsl:copy-of select="$vmeta" />
      <bookdata>
        <xsl:copy-of select="$vbook" />
        <contents pdf="parent::contents/@pdf">
          <xsl:copy-of select="." />
        </contents>
      </bookdata>
    </book>
  </xsl:document>
</xsl:template>

However, last time I checked, XSLT 1.0 didn't support multidoc output unless
extensions are used..


Hope this helps!

Cheers,

Andreas


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



<Prev in Thread] Current Thread [Next in Thread>