cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sandor Spruit <>
Subject Re: multiple xpaths
Date Sun, 02 Oct 2005 19:04:44 GMT
David wrote:

>  I am writing a cocoon transformer and need to know when any of
>  multiple xpaths match. I'm sure there must be a be a more efficient
>  way then converting it to a DOM document and then running each xpath
>  to get the nodelist of each.

Don't know about the best way, but I had a similar problem recently:
I wanted to apply a transformation to specific elements, pointed to by
an XPath expression. The basic problem was that XSLT will not allow
a variable where it expects an XPath, i.e. xsl:template match="$xpath".

One of our students came up with this idea: create the *stylesheet* in a
separate (internal) Cocoon pipeline. Create a placeholder in your XSLT
where you'd normally insert an XPath expression, i.e. 'please-replace-me',
and define a variable for this stylesheet. Write a simple stylesheet to copy
the "stylesheet" template, but replacing the placeholder with your XPath.

Use the result of this pipeline ('a dynamic stylesheet') from your regular
Cocoon pipeline using the cocoon:/ pseudo-protocol.

This works like a charm; the approach can be expanded to work with
multiple XPath expressions. Hope my explanation it clear enough. I'd
post an example, but it's on our server my laptop. Maybe later?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message