cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morus Walter <morus.wal...@tanto.de>
Subject dynamic selection of stylesheet
Date Wed, 24 Nov 2004 10:18:11 GMT
Hi,

I'm new to cocoon and was trying to do a simple test application 
reimplementing the core of some php application we are running.

The application consists of a search for xml articles, displaying
a hit list and displaying the articles itself using xslt.
The articles have different but similar doctypes and we have one
default xslt stylesheet and for some of the doctypes specialized 
stylesheets that extend the default stylesheet (calling the default
stylesheet via xsl:import and overwrite some of the templates).

Most things worked fine but I'm having problems, how to choose the
right stylesheet.
I have the xml document and its doctype and have to check if there
is a specialized stylesheet. If I find one, that's the stylesheet to
use, otherwise the default stylesheet should be used.

How would that be done in cocoon?

The solution I found so far, is to have a flowscript checking for
the file. This has two problems: 
a) I had to use the absolute path to the file instead of a relative 
   pathname (currently in the flowscript itself. I guess it wouldn't be
   a problem to move that to some parameter. But as long as I need
   the absolute path, it's ugly anyway). Any way to avoid that?
b) If I use the flowscript to select the stylesheet itself returning 
   a call to a pipeline reading the stylesheet and serializing it as
   xml, I can select the default stylesheet, but the specialized stylesheets
   break since they cannot import the relative adressed default stylesheet
   any longer. Seems the base path got lost, when the stylesheet was read
   by a file generator.
   So instead I have two pipelines for handling the article content now,
   one of them using 
	<map:transform src="xslt/html/{request-param:doctype}.xsl">
   the other 
        <map:transform src="xslt/html/default.xsl">
   and the flowscript selects which one to use for the article 
   transformation.
   That doesn't look like a reasonable solution to me, though.

Another problem I didn't look into so far is, how to get the doctype of
the articles dynamically. Currently it's provided by the search result
but it would be nicer, if I could read it from the xml instance itself.

Thanks for your help
       Morus

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


Mime
View raw message