Hiral Parikh wrote:
> I am doing a bunch of XSL transformations from an XML file using Cocoon
> 2.1.5.1 and finally generate a FO file.
>
> I have the following requirement to carry out in my XSL transformations:
> 1. Get the fileurl for images in the XML (e.g. /images/A.jpg) 2. Check for
> the file on a physical location 3. If the file exist then ok, otherwise
> change the file url (/images/A_temp.jpg).
You should avoid the XSLT document() function, since it will break the
pipeline cacheability.
You could transform the URLs in the source document into xinclude elements
which refer to another cocoon pipeline. After this transformation you
transform with the xinclude transformer and it will call the other pipeline.
This second pipeline could use the directory generator to search for the
A.jpg file, and if it's not there, to use the backup URL. Something like
this (NB this is not tested):
<!-- in xslt -->
<xsl:template match="foo/@image-url">
<xl:include href="cocoon:/get-image-url{.}"/>
</xsl:template>
<!-- in sitemap -->
<map:match pattern="get-image-url/*.jpg">
<map:generate type="directory">
<map:parameter name="name" value="{1}.jpg"/>
</map:generate>
<!-- if directory generator didn't find the file, replace it with a
fallback URL -->
<map:transform src="xsl/get-image-url.xsl">
<map:parameter name="fallback-url" value="{1}_temp.jpg"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>
Hope that helps!
Con
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]