cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antonio Gallardo" <agalla...@agsoftware.dnsalias.com>
Subject Re: Passing parameter from sitemap
Date Tue, 20 Jan 2004 07:33:54 GMT
Dmitry Diskin dijo:
> Hi,
>
> I'm looking for a way to pass some constant parameter from sitemap to
> all my xsl styles. Basically I need to replace multiple occurences (bad
> design! not mine :)) of "(c) 2001-2003" to something like "(c)
> 2001-${currentyear}", where "currentyear" will be defined in single
> place (sitemap, sub-sutemap?).

One posible solution is using XInclude. We use it to set some particular
variables for our applications. Note we use some generic xslt to make
rendering. I think this could help you too. Sample:

Description: We have some variables names for every application that have
his own values: application name, author, copyright notice, etc.

The solution using XInclude is very easy, just 3 steps:

Here is the basic XML that store this particular data for each application
(sorry the tags are in spanish, but I hope you can get the idea from):

1- Write a file with tags that will contain all the particular data for
each application:

********************** appdata.xml ******************************
<aplicacion>
    <nombre>My app name</nombre>
    <titulo>The title of the App</titulo>
    <elaborado>Who made the App</elaborado>
    <html>
        <meta name="author" content="An author notice"/>
        <meta name="copyright" content="The copyright notice"/>
        <meta name="date" content="Start date"/>
    </html>
    <documentacion>Who made the documentation</documentacion>
    ......
</aplicacion>
*****************************************************************

2-Then in a xslt we use XInclude:

************************** render2html.xslt *********************
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude">
    <xsl:template match="document">
        <html lang="es-NI">
            <head>
                <xi:include
href="context:///resources/datosapp.xml#xpointer(/aplicacion/html/node())"/>
*****************************************************************

3-In the sitemap.xmap you will use the xinclude transformer after the
stylesheet that render the page. In this case render2html.xslt:

....
<map:transform src="stylesheets/render2html.xslt"/>
<map:transform type="xinclude"/>
....
*****************************************************************

For more info about XInclude:
http://cocoon.apache.org/2.1/userdocs/transformers/xinclude-transformer.html

I hope this help.

Best Regards,

Antonio Gallardo



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message