You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Richard Lewis <ri...@fastmail.co.uk> on 2004/09/20 14:10:12 UTC

Resources from within XSLT

Hi there,

Say part of my main content XML has the name of an image (with no path) 
in an element called <image> and the image itself is stored in a 
directory such as /resources/images (while the content is in /content 
and the stylesheets are in /stylesheets).

Also suppose I'm using a 'virtual directory' scheme (e.g. 
//host/people/staff really refers to sections and subsections within 
the content, not a directory structure on the server). How can I get a 
transforming XSLT stylesheet to complete the URI of the image from the 
name given in the <image> element so that it points to the image 
correctly?

Cheers,
Richard


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


Re: Resources from within XSLT

Posted by Jean-Baptiste Quenot <jb...@anyware-tech.com>.
* Richard Lewis:

> * Jean-Baptiste Quenot:

> > <map:parameter name='resource.path' value='/resources/images'/>

> <parameter name="resources" value="/cocoon/studio/resources"/>

Shall I recommend not to omit the « map: » prefix?
-- 
Jean-Baptiste Quenot
Anyware Technologies
http://www.anyware-tech.com/

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


Re: Resources from within XSLT

Posted by Richard Lewis <ri...@fastmail.co.uk>.
Thanks for your reply,
On Monday, Sep 20, 2004, at 13:29 Europe/London, Jean-Baptiste Quenot 
wrote:

> * Richard Lewis:
>
>> How can  I get a transforming  XSLT stylesheet to complete  the URI of
>> the image from the name given in the <image> element so that it points
>> to the image correctly?
>
> The best way to deal with resources path is to pass a parameter to the
> transformation in the sitemap, and get that parameter in the 
> stylesheet.
>
> sitemap:
>
> <map:transform src='my.xsl'>
>   <map:parameter name='resource.path' value='/resources/images'/>
> </map:transform>
>
> xsl:
>
> <xsl:param name='resource.path'/>
>
> <img src='{$resource.path}/ok.png'/>
>
I've actually tried this one but it still doesn't work.

Here's a clipping from my sitemap:

<map:match pattern="*/*">
	.....
	<map:transform src="html/index.xsl">
		<parameter name="section" value="{1}" />
		<parameter name="subsection" value="{2}" />
		<parameter name="resources" value="/cocoon/studio/resources" />
	</map:transform>
</map:match>

and from index.xsl:

<xsl:param name="resources" />
....
<xsl:template match="picture">
	<div class="picture">
		<xsl:if test=".!=''">
			<img src="{$resources}/{.}" alt="{../name}" />
		</xsl:if>
		<xsl:if test=".=''">
			<img src="{$resources}/unknown.gif" alt="{../name}" />
		</xsl:if>
	</div>
</xsl:template>

So, by the time the <picture> element is parsed, the URL is in the 
format:
http://server:8080/cocoon/studio/section/subsection

where 'subsection' is effectively (as I understand it, correct me if 
I'm wrong) the resultant HTML document from which the path to the image 
resource must be correct.

Should the (absolute?) path to image I've tried to use be correct? It 
doesn't work ATM.

Cheers,
Richard


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


Re: Resources from within XSLT

Posted by Jean-Baptiste Quenot <jb...@anyware-tech.com>.
* Richard Lewis:

> How can  I get a transforming  XSLT stylesheet to complete  the URI of
> the image from the name given in the <image> element so that it points
> to the image correctly?

The best way to deal with resources path is to pass a parameter to the
transformation in the sitemap, and get that parameter in the stylesheet.

sitemap:

<map:transform src='my.xsl'>
  <map:parameter name='resource.path' value='/resources/images'/>
</map:transform>

xsl:

<xsl:param name='resource.path'/>

<img src='{$resource.path}/ok.png'/>

HTH,
-- 
Jean-Baptiste Quenot
Anyware Technologies
http://www.anyware-tech.com/

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