cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Noels <stev...@outerthought.org>
Subject (don't laugh) single-element logicsheet for accessing sitemap parameters
Date Thu, 13 Mar 2003 12:44:34 GMT
Hi,

to my surprise, I didn't find a clean way (logicsheet) to retrieve the 
value of a sitemap parameter in an XSP, only request parameters are 
supported IIUC by request.xsl.

So I cooked up a dead-simple sitemap.xsl logicsheet which offers a 
get-parameter element which calls parameters.getParameter().

Since I might have overlooked the existence of such a thing (2.0.5-dev)? 
I'm just checking whether it is OK to commit (as you all know I'm not to 
be trusted when it comes to code ;-)

Here's what I've done:

added to cocoon.xconf:


<!-- The sitemap taglib has only one element get-parameter which enables 
you to retrieve the value of a sitemap
      parameter -->

   <builtin-logicsheet>
     <parameter name="prefix" value="sitemap"/>
     <parameter name="uri" value="http://apache.org/xsp/sitemap/1.0"/>
     <parameter name="href" 
value="resource://org/apache/cocoon/components/language/markup/xsp/java/sitemap.xsl"/>
   </builtin-logicsheet>


sitemap.xsl:

<xsl:stylesheet version="1.0"
                 xmlns:xsp="http://apache.org/xsp"
                 xmlns:xsp-sitemap="http://apache.org/xsp/sitemap/1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:template match="xsp-sitemap:get-parameter">
     <xsp:expr>(parameters.getParameter("<xsl:value-of 
select="@name"/>", null))</xsp:expr>
   </xsl:template>


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

</xsl:stylesheet>

and you can use it like this in an XSP:

<?xml version="1.0"?>
<xsp:page xmlns:xsp="http://apache.org/xsp"
           xmlns:cinclude="http://apache.org/cocoon/include/1.0"
           xmlns:xsp-sitemap="http://apache.org/xsp/sitemap/1.0">
   <html xmlns="http://www.w3.org/TR/xhtml1">
     <head>
       <title>The Foobar website</title>
       <link rel="stylesheet" href="some_stylesheet.css" />
     </head>
     <body>
       <cinclude:include><xsp:attribute 
name="src"><xsp-sitemap:get-parameter 
name="document-id"/></xsp:attribute></cinclude:include>
     </body>
   </html>
</xsp:page>

Good idea?

</Steven>
-- 
Steven Noels                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at            http://blogs.cocoondev.org/stevenn/
stevenn at outerthought.org                stevenn at apache.org


Mime
View raw message