From: "Omar Adobati" <[EMAIL PROTECTED]>
Date: Fri, 21 Jul 2006 12:03:05 +0200

> I worked around that by passing in the host/port/context (read from the
> request object) as a parameter to the XSL transformation.  You could do
much
> the same with Cocoon using something like
> <map:transform type="xsl" src="whatever.xsl">
>    <map:parameter name="baseUrl"
>
value="http://{request:serverName}:{request:serverPort}{request:contextPath}"/>
> in your sitemap and
> <xsl:param name="baseUrl"/>
> ...
> <fo:external-graphic
src="{$baseUrl}/images/my_logo.png"/>
> in the XSLT stylesheet.  This avoids having to hard code the server in
your
> XSL.

I tried to do this into my sitemap.xmap

   <map:match pattern="*.jpg">
     <map:parameter name="baseUrl"
value="http://{request:serverName}:{request:serverPort}{request:contextPath}"/>
     <map:read mime-type="image/jpg" src="img/{1}.jpg"/>
   </map:match>

Wrong place. The baseUrl is to be passed into the XSL transformation, the reader that's returning the bitmap doesn't need to know it. And besides, even if you had a reader that e.g. embedded the URL in an EXIF field in the JPEG, you'd have to put the parameter inside the <map:read> element rather than inside the <map:match>. You'd only need it there if the wildcard URI matcher were written to expect a parameter of that name.

and I tried to put it also here:

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

You need to use
          <map:transform src="xsl/xml2html.xsl">
<map:parameter name="baseUrl" value="http://{request:serverName}:{request:serverPort}{request:contextPath}"/>
          </map:transform>
and the transformer will then pass the parameter to the XSL transformation engine, which will allow you to access it within xml2html.xsl using a top-level (at the start, outside any xsl:template) <xsl:param name="baseUrl"/> element. Then, when you output the external-graphic elements, use <fo:external-graphic src="{$baseUrl}/whatever.jpg"/>

but seems that baseUrl is a blank string... so it doesn't work for me...
could you suggest me why?
IT could depends by the fact that I'm actually running cocoon in Tomcat?

The container shouldn't matter, I've used this technique running in Tomcat on my own machine, then deployed the same war to Websphere. It worked the same in both.


Andrew.



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

Reply via email to