cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davor Cengija <dceng...@mcs.hr>
Subject RE: AW: one XML file but various XSL styles
Date Tue, 31 Oct 2000 21:05:59 GMT
	Hi Kirk and everybody...

On Tue, 31 Oct 2000, Kirk Woerner wrote:

>You can also do it by including whichever stylesheet you want
>This really ought to be in the fact as well as the XSP method shown I
>think...
>

	This solution helped me a lot, as well. I asume you typed it
	directly, since it has some minor mistakes...

>
><a href="chapter.xml?style=full.xsl">show full</a>
>
>chapter.xml:
><?xml-stylesheet href="style.xsl" type="text/xsl"?>

<?cocoon-process type="xslt"?> is needed here.

>style.xsl
><?xml version="1.0"?>
><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>version="1.0">
>
><!-- this is internal reference to the "style=" in the url -->
> <xsl:param name="style"/>
>
> <xsl:template match="/">
>  <xsl:choose>
>   <!-- when "style" is specified ... -->
>   <xsl:when test="$style">
>    <xsl:variable name="href">/stylesheets/<xsl:value-of
>select="$style"></xsl:variable>

<xsl:value-of select="$style"/>  <-- missing closing slash -->

	However, I don't understand do we actually need xsl:variable
	here?

>    <xsl:processing-instruction name="xml-stylesheet">
>       href="$style" type="text/xsl"

	This doesn't work (at least not in Cocoon 1.8). It complains
	about not finding /path/$style file ($style is not expanded).
	The solution is to have this:

href="<xsl:value-of select="$style"/>"


	The rest is OK. Here's the .xsl which I use:


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:param name="style"/>

	<xsl:template match="/">
	 <xsl:choose>
	  <!-- when style is specified -->
	  <xsl:when test="$style">
	   <!-- xsl:variable name="href"><xsl:value-of select="$style"/></xsl:variable
-->
	   <xsl:processing-instruction name="xml-stylesheet">
	    href="<xsl:value-of select="$style"/>" type="text/xsl"
	   </xsl:processing-instruction>
	   <xsl:processing-instruction name="cocoon-process">
	    type="xinclude"
	   </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="stylepdf.xsl" type="text/xsl"
		</xsl:processing-instruction>
	   <xsl:processing-instruction name="cocoon-process">
	    type="xinclude"
	   </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>

-- 
      v
Davor Cengija
dcengija@mcs.hr
===========================
"Nicht mit Alkohol mischen"


Mime
View raw message