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?

cheers,
Sandor

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

Reply via email to