You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Thorbjørn Ravn Andersen <TR...@stibo.dk> on 2000/08/29 14:48:43 UTC

RE: Cocoon's issues with multiple stylesheets / multiple input do cuments

> to - the stylesheet is bolted onto the XML as surely as if 
> they were the same
> file.

Cocoon 1 does not have any provisions for using an external mechanism to decide what style sheets to apply to a given XML file, but the Processing Instruction you are having trouble with.

The standard answer is to use Cocoon 2 since such a mechanism is available there, but I have not tried it myself.

-- 
  Thorbjørn Ravn Andersen             "...and...Tubular Bells!"
  http://bigfoot.com/~thunderbear

Re: Cocoon's issues with multiple stylesheets / multiple input do cuments

Posted by Aurélien DEHAY <au...@sncf.fr>.
Thorbjørn Ravn Andersen <TR...@stibo.dk> writes:

> > to - the stylesheet is bolted onto the XML as surely as if 
> > they were the same
> > file.
> 
> Cocoon 1 does not have any provisions for using an external
> mechanism to decide what style sheets to apply to a given XML file,
> but the Processing Instruction you are having trouble with.

But Cocoon offers to do a thing like this:

<?cocoon-process type="xslt"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <xsl:param name="format">html</xsl:param>

  <xsl:template match="document">
	 <xsl:choose>
		<xsl:when test="$format='pdf'">
		  <xsl:processing-instruction name="cocoon-format">type="text/xslfo"</xsl:processing-instruction>
		  <xsl:processing-instruction name="xml-stylesheet">version="1.0" href="/styles/xsl/document-pdf.xsl"</xsl:processing-instruction>
		</xsl:when>
		<xsl:when test="$format='html'">
		  <xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
		  <xsl:processing-instruction name="cocoon-format">type="text/html"</xsl:processing-instruction>
		  <xsl:processing-instruction name="xml-stylesheet">version="1.0" href="/styles/xsl/document-html.xsl" type="text/xsl"</xsl:processing-instruction>
		</xsl:when>
	 </xsl:choose>

	 <xsl:copy>
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates select="node()"/>
	 </xsl:copy>
  </xsl:template>

  <xsl:template match="@*|*|text()">
	 <xsl:copy>
		<xsl:apply-templates select="@*|*|text()"/>
	 </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

Maybe it's not a beautifull peace of code, it's work.

> 
> 
> The standard answer is to use Cocoon 2 since such a mechanism is
> available there, but I have not tried it myself.

When snapshots of the CVSROOT will be online? I can't access to the
CVS (it's just beaucoup we don't have masquering here: whe're behind a
proxy).

-- 
Aurélien