You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by John Menke <jo...@eagleinfosystems.com> on 2001/02/09 00:58:50 UTC
Dynamic selection of stylesheets
I have been to http://tecfa.unige.ch/guides/xml/cocoon/dynamic-xslt/ . I
have tried to use the code in my site and have had unpredictable results.
Here is the xsl used in the example to do the dynamic selection:
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="portal" />
- <xsl:template match="page">
<xsl:processing-instruction
name="cocoon-process">type="xslt"</xsl:processing-instruction>
- <xsl:processing-instruction name="xml-stylesheet">
href="
- <xsl:choose>
<xsl:when test="$portal='hip'">hip.xsl</xsl:when>
<xsl:when test="$portal='hop'">hop.xsl</xsl:when>
<xsl:otherwise>error.xsl</xsl:otherwise>
</xsl:choose>
" type="text/xsl"
</xsl:processing-instruction>
- <xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
- <xsl:template match="*|@*">
- <xsl:copy>
<xsl:apply-templates select="@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Although the code works great with the example files, when I switch to my
own pages. I get unpredictable results. Does anyone have any example code
or ideas on how to do this? Can you do it with XSP?
RE: Dynamic selection of stylesheets
Posted by John Menke <jo...@eagleinfosystems.com>.
Somebody answered this question under a different subject:
This works:
<xsp:logic>
String stylesheet = "filename.xsl";
</xsp:logic>
<xsp:pi target="xml-stylesheet">
href="<xsp:expr>stylesheet</xsp:expr>"
type="text/xsl"
</xsp:pi>
> -----Original Message-----
> From: John Menke [mailto:john@eagleinfosystems.com]
> Sent: Thursday, February 08, 2001 6:59 PM
> To: Cocoon-Users Apache.
> Subject: Dynamic selection of stylesheets
>
>
> I have been to http://tecfa.unige.ch/guides/xml/cocoon/dynamic-xslt/ . I
> have tried to use the code in my site and have had unpredictable results.
> Here is the xsl used in the example to do the dynamic selection:
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> - <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:param name="portal" />
> - <xsl:template match="page">
> <xsl:processing-instruction
> name="cocoon-process">type="xslt"</xsl:processing-instruction>
> - <xsl:processing-instruction name="xml-stylesheet">
> href="
> - <xsl:choose>
> <xsl:when test="$portal='hip'">hip.xsl</xsl:when>
> <xsl:when test="$portal='hop'">hop.xsl</xsl:when>
> <xsl:otherwise>error.xsl</xsl:otherwise>
> </xsl:choose>
> " type="text/xsl"
> </xsl:processing-instruction>
> - <xsl:copy>
> <xsl:apply-templates select="@*" />
> <xsl:apply-templates select="node()" />
> </xsl:copy>
> </xsl:template>
> - <xsl:template match="*|@*">
> - <xsl:copy>
> <xsl:apply-templates select="@*" />
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
>
>
> Although the code works great with the example files, when I switch to my
> own pages. I get unpredictable results. Does anyone have any example code
> or ideas on how to do this? Can you do it with XSP?
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>