[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Dynamic stylesheet selection

Subject: Re: Dynamic stylesheet selection
From: Ruben Inoto <ris2@xxxxxxxxx>
Date: Wed, 04 Apr 2001 14:55:47 +0200
stylesheet select
> 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.