cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@socialchange.net.au
Subject Re: Cocoon
Date Sat, 06 Jan 2001 06:15:31 GMT


> Hi,
> 
> Cocoon knows what a .xml files he has to let parse.
> XSP is from Cocoon.

Cocoon is just a fancy servlet.. it figures out the file 
name from standard HttpServletRequest fields.

> 
> So how can I get the .XML's file name from my XSP
> code inside.

Here's an example XSP and taglib that illustrate:
 - getting the XSP name
 - getting the name of the calling XSP from a taglib
 - other stuff (XSP-ENVIRONMENT, etc) accessible
    from the taglib

---- simple.xml ----
<?xml version='1.0'?>
<?cocoon-process type="xsp"?>
<?xml-logicsheet href="taglib.xsl"?>
<?cocoon-format type="text/html"?>

<xsp:page language="java"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  xmlns:request="http://www.apache.org/1999/XSP/Request"
  xmlns:taglib="http://www.socialchange.net.au/~jeff/taglib"
>
<html>
    <body>
        The XSP page (from XSP): <request:get-request-uri/><br />
        The XSP page (from taglib): <taglib:geturi/><br />
        Other stuff visible in the taglib:<br />
        <taglib:otherstuff/>

    </body>
</html> 
    
</xsp:page>
--------

---- taglib.xsl ----
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:taglib="http://www.socialchange.net.au/~jeff/taglib"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core">

<xsl:param name="filename"/>
<xsl:param name="language"/>
<xsl:param name="XSP-ENVIRONMENT"/>
<xsl:param name="XSP-VERSION"/>

<xsl:template match="xsp:page">
    <xsp:page>
        <xsl:copy>
            <xsl:apply-templates select="@*" />
        </xsl:copy>
        <xsl:apply-templates />
    </xsp:page>
</xsl:template>
    
<xsl:template match="taglib:geturi">
<xsl:value-of select="$filename"/>
</xsl:template>

<xsl:template match="taglib:otherstuff">
    language: <xsl:value-of select="$language"/><br />
    XSP-ENVIRONMENT: <xsl:value-of select="$XSP-ENVIRONMENT"/><br />
    XSP-VERSION: <xsl:value-of select="$XSP-VERSION"/><br />
</xsl:template>

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

</xsl:stylesheet>
--------


--Jeff


> 
> Does that anyone know?
> 
> Thanks in advance,
> 
> Christian Parpart
> SurakWare
> cparpart@surakware.com
> http://surak.cocoonhost.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


Mime
View raw message