Re: [xsl] Conversion from xsl to xsl:fo

Subject: Re: [xsl] Conversion from xsl to xsl:fo
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 24 Oct 2001 12:07:23 +0100
Max,
> I thought of writing a stylesheet that will convert an XSLT stylesheet
> that produces an XHTML document to an XSLT stylesheet that produces FO
> (i.e. an XSL stylesheet) but I found it hard or not really possible to
> do. I don't remember why.

There are (at least) two ways to get from 
"(1): a stylesheet producing X" and "(2): a styleheet converting X to Y"
to "(3): a stylesheet producing Y"

plan a)
write a stylesheet that takes (1) as input and modifies all the
templates so that where they use constructions from the language X
the result is a template using constructions from language Y.
There is an example of a stylesheet which convers HTML generators to
XHTML generators in the MathML distribution (and the archives of this
list). This can get tricky if you want to spot xsl:element constructions
using Xpath expressions that might dynamically evaluate to constructs in
language X. (Spotting literal result elements is a lot easier)

plan b)
is to use a xx:node-set extension and just write stylesheet (3) like so:

<xsl:import href="stylesheet1"/>
<xsl:import href="stylesheet2"/>

<xsl:variable name="tmp">
 <xsl:apply-templates/>
</xsl:variable>

<xsl:template match="/">
 <xsl:apply-templates mode="convert" select="xx:node-set($tmp)"/>
</xsl:template>


(assuming all the templates in stylesheet 2 use the "convert" mode)

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

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


Current Thread