|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Dynamic stylesheet selection
> Hi,
> This is probably a FAQ, but I haven't found the answer (other than
> _no_): is it possible to choose one stylesheet or another based on
> input, or the only way to do that is to choose different modes for a
> template within the same stylesheet?
>
I don't know if is something like this what you are looking for, maybe it can
help you...
Here I use an XSL "father" that 'creates' the same XML that has called him, but
with the call to the desired XSL depending on the parameter passed via URL to the
XML. (Don't ask me about performance). Note that I'm using Cocoon...
//Ruben
----------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Variable pasada por parametro via URL al XML (http://fich.xml?imprimir=html)
-->
<xsl:param name="imprimir">0</xsl:param>
<!-- Aplica el template a la raiz del documento XML -->
<xsl:template match="/">
<!-- Dependiendo de si es para imprimir o no llama a articulo.pdf.xsl -->
<xsl:choose>
<xsl:when test="$imprimir='pdf'">
<xsl:processing-instruction name="xml-stylesheet">
href="../xsl/articulo.pdf.xsl" type="text/xsl"
</xsl:processing-instruction>
<xsl:processing-instruction name="cocoon-process">
type="xslt"
</xsl:processing-instruction>
</xsl:when>
<xsl:when test="$imprimir='html'">
<xsl:processing-instruction name="xml-stylesheet">
href="../xsl/articulo.html.xsl" type="text/xsl"
</xsl:processing-instruction>
<xsl:processing-instruction name="cocoon-process">
type="xslt"
</xsl:processing-instruction>
</xsl:when>
<xsl:otherwise>
<xsl:processing-instruction name="xml-stylesheet">
href="../xsl/articulo.capitulos.xsl" type="text/xsl"
</xsl:processing-instruction>
<xsl:processing-instruction name="cocoon-process">
type="xslt"
</xsl:processing-instruction>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="@*|*|text">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
-------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








