cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geert Josten <Geert.Jos...@daidalos.nl>
Subject Re: XSL File I/O
Date Fri, 18 Feb 2005 18:06:32 GMT
> 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. 

There might be a more greedy match before this one, or in a 'higher' sitemap (= closer to
webapp 
root dir).

Or could be that you just need to use ** instead of *?

> 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

Once again: most obvious option is document(), but because of the earlier mentioned bug, you
might 
not want to use it. Though, placing your <generate type="directory"/> in a <pipeline

type="non-caching"> might circumvent the bug. Haven't tested.

Alternatively, you could add a literal <xi:include> in your xsl and transform it with
<transform 
type="xinclude"> _before_ using it in a <transform type="xsl">. Much more code though.
It will more 
or less look like this:

<map:match pattern="get-images.xml">
   <map:generate type="directory">
     <map:parameter name="include" value="*.jpg"/>
   </map:generate>
   <map:serialize type="xml"/>
</map:match>

<map:match pattern="**.xsl">
   <map:generate src="{1}.xsl"/>
   <map:transform type="xinlcude"/>
   <map:serialize type="xml" />
</map:match>

<map:match pattern="process-images/**">
   <map:generate src="cocoon:/{1}" />
   <map:transform src="cocoon:/process-images.xsl"/>
   <map:serialize type="xml" />
</map:match>

<!-- and in your xsl -->

<xsl:stylesheet ...>

   <xi:include src="cocoon:/get-images.xml" parse="xml" /> <!-- syntax correct? -->

   <xsl:variable name="images" select="document('')/dir:directory/dir:file" /> <!--
make sure to 
define the dir namespace -->

   <xsl:template match="foo/@image-url">
     <xsl:variable name="image" select="$images[@name = current()/@image-url]"/>
     <xsl:variable name="image_temp" select="$images[@name = 
concat(substring-before(current()/@image-url, '.jpg'), '_temp.jpg')]"/>
     <xsl:choose>
       <!-- sorry, bit lazy -->
       when $image insert image url
       when $image_temp insert image_temp url
       otherwise ???
     </xsl:choose>
   </xsl:template>

Once again, haven't tested, but should work i think... :)

Cheers...



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message