You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stefan Seifert <ss...@pro-vision.de> on 2002/01/03 14:03:27 UTC
AW: Specifying XSL sheet for client side translation in XSP?
I solved a similiar problem using a XSL stylesheet which only puts a
xml:stylesheet processing instructing in the resulting XML-Stream before
it is send to the browser.
Use a stylesheet like this (i called it "add_stylesheet_pi.xsl"):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:param name="stylesheet"/>
<xsl:template match="*">
<xsl:text disable-output-escaping="yes"><?xml-stylesheet
type="text/xsl" href="</xsl:text><xsl:value-of
select="$stylesheet"/><xsl:text
disable-output-escaping="yes">"?></xsl:text>
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
And correct your Sitemap as follows:
<map:match pattern="browsertest/">
<map:generate src="reci-vba.xml"/>
<map:select type="browser">
<map:when test="explorer6">
<map:transform src="stylesheets/add_stylesheet_pi.xsl">
<map:parameter name="stylesheet"
value="stylesheets/reci2r.xsl"/>
</map:transform>
<map:serialize type="xml"/>
</map:when>
<map:otherwise>
<map:transform src="stylesheets/reci2r.xsl"/>
<map:serialize type="html"/>
</map:otherwise>
</map:select>
</map:match>
Stefan
> -----Ursprüngliche Nachricht-----
> Von: Rune Sandnes [mailto:rune@klapp.no]
> Gesendet: Freitag, 28. Dezember 2001 15:44
> An: cocoon-users@xml.apache.org
> Betreff: Specifying XSL sheet for client side translation in XSP?
>
>
>
> I have gotten the browser-detection features to work with Cocoon 2, I
> plan to serve
> raw XML and XSL to users of Explorer 6, so they can do the
> XSL-transformation client-side,
> Cocoon will do the transformation for other browsers.
>
> My sitemap looks like this, and it works nicely for static files:
>
> <map:match pattern="browsertest/">
> <map:generate src="reci-vba.xml"/>
> <map:select type="browser">
> <map:when test="explorer6">
> <map:serialize type="xml"/>
> </map:when>
> <map:otherwise>
> <map:transform src="stylesheets/reci2r.xsl"/>
> <map:serialize type="html"/>
> </map:otherwise>
> </map:select>
> </map:match>
>
> (The string "explorer6" is defined further up in the sitemap, with
> <browser name="explorer6" useragent="MSIE 6"/>
> i the <map:selector bane="browser"> section)
>
> The start of the XML file in question looks like this:
>
> <?xml version="1.0" ?>
> <?xml:stylesheet type="text/xsl" href="/stylesheets/reci2r.xsl" ?>
>
> The <?xml:stylesheet> part is ignored when Cocoon does the
> transformation, the
> transform specified in the sitemap takes preference.
>
> My problem is that I don't want to serve static XML files,
> but generated
> content
> through XSP. When I try to do this operation with a generated
> XSP file I
> can't
> seem to get the <?xml:stylesheet> instruction through to the
> client. It
> just
> disappears, no matter where in the XSP file I put it.
>
> Anyone know how to do this?
>
>
> Thanks,
> Rune,
> Klapp Media,
> Trondheim, Norway
>
> ---------------------------------------------------------------------
> 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>
>
>
>
>
>
---------------------------------------------------------------------
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>
Re: AW: Specifying XSL sheet for client side translation in XSP?
Posted by Joerg Heinicke <jh...@virbus.de>.
> Use a stylesheet like this (i called it "add_stylesheet_pi.xsl"):
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:strip-space elements="*"/>
> <xsl:param name="stylesheet"/>
> <xsl:template match="*">
> <xsl:text disable-output-escaping="yes"><?xml-stylesheet
> type="text/xsl" href="</xsl:text><xsl:value-of
> select="$stylesheet"/><xsl:text
> disable-output-escaping="yes">"?></xsl:text>
> <xsl:copy-of select="."/>
> </xsl:template>
> </xsl:stylesheet>
Why not using <xsl:processing-instruction>?
<xsl:processing-instruction name="xml-stylesheet">
<xsl:text>type="text/xsl" href="</xsl:text>
<xsl:value-of select="$stylesheet"/>
<xsl:text>"</xsl:text>
</xsl:processing-instruction>
In general try to avoid disable-output-escaping!
Regards,
Joerg
--
System Development
VIRBUS AG
Fon +49(0)341-979-7411
Fax +49(0)341-979-7409
joerg.heinicke@virbus.de
www.virbus.de
---------------------------------------------------------------------
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>