Hi Conal,

I tried the following:
<!-- in xslt -->
<xsl:template match="foo/@image-url">
        <xsl: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>


But for some reason it does not go to the sitemap
pattern="get-image-url/*.jpg".
I renamed the pattern name in the sitemap to something else so that it does
not match, just to check if the Cocoon throws any error. But no error. 

I know that the XSL matches the template <xsl:template
match="foo/@image-url"> as I am able to print some debug statements.
I tried <xi:include>,bu obviously it just inserted that line of code in the
outcoming XML.

How can I transfer the control to Cocoon sitemap from the XSL and then get
the XML inserted in the XSL?
In simple words:
        <xsl:template match="foo/@image-url">
                Go to Sitemap to match some pattern "get-image-url{.}"
                Do the transformation 
        Get the XML back in this XSL
        Continue with transformation


Thanks,
Hiral





-----Original Message-----
From: Conal Tuohy [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 16, 2005 10:42 PM
To: [email protected]
Subject: RE: XSL File I/O

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]




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

Reply via email to