  | |  | dynamic selection of stylesheet | dynamic selection of stylesheet 2004-11-25 - By Derek Hohls
Back Morus
It seems you should be able to do element matching in your stylesheets, based on the doctype/namespace of the document itself - eg. see the oblique reference at:
http://www.dpawson.co.uk/xsl/sect2/N2281.html#d3521e292
This would remove the need to do any kind of flowscript or pipeline macthing. Having said that, I cannot get a sample to work & have posted for help on the XSL mail list.
Derek
>>> morus.walter@(protected) 2004/11/24 12:18:11 PM >>> 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@(protected) For additional commands, e-mail: users-help@(protected)
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks transtec Computers for their support.
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ To unsubscribe, e-mail: users-unsubscribe@(protected) For additional commands, e-mail: users-help@(protected)
Earn $52 per hosting referral at Lunarpages.
|
|
 |