Antonio Gallardo wrote:

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

Thank you, Antonio!


However, this is not exactly what I want since I'll have to add <xi:include ... /> to each xsl file. I will do it, of course, if no other solutions exist. Ideally, I want to define something in sitemap (or include something just once), and then use it in each xsl file without including additional files.

--
Regards,
Dmitry.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to