You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Bob Harrod <rj...@gmail.com> on 2012/05/16 06:52:24 UTC

Cocoon 2.1 web application base path

I'm quite new to cocoon, and supporting an older version (2.1).  Does
anyone know how I can gain access the web application base path inside of a
transform?  Of course, it can be passed by the sitemap...  Any help would
be appreciated!

Thanks!

Re: Cocoon 2.1 web application base path

Posted by Javier Puerto <jp...@gmail.com>.
2012/5/16 Bob Harrod <rj...@gmail.com>

> Ok, thank you!  I can look at the LinkRewriterTransformer.  Since I'm new
> to this, I have some follow up questions:
>
> 1. Is this a "plugin" that I have to install or does it exist in the stock
> version of cocoon 2.1?
>

It's included as a block for cocoon-2.1 and it's builded with cocoon-2.1 by
default but I've used it for Cocoon 2.2 & 3 so I'm not sure how to
configure it. I remember that you have to declare the component at the
beginning of the sitemap before use it. You can browse the block code and
samples for linkrewritter here

http://svn.apache.org/viewvc/cocoon/tags/cocoon-2.1/RELEASE_2_1_11/src/blocks/linkrewriter/

Or even better, download the sources and play a bit with the samples :)

http://svn.apache.org/repos/asf/cocoon/tags/cocoon-2.1/RELEASE_2_1_11


> 2. The examples reference the transformer from a sitemap context.  Is
> there a way to use the LinkRewriterTranformer directly from another
> transform (as this transform is actually creating the anchor)?
>

The LinkRewriterTransformer is a transformer component for pipeline process
and must be used from a sitemap context. You should place the transformer
in the pipeline so the links get transformed to the right location, usually
at the end of the pipeline before the serializer.

<map:pipeline>
...

  <map:match pattern="welcome">
    <map:generate src="welcome.xml">
    <map:transform src="xslt/xml2page.xsl"/> <!-- your transformation -->
    <map:transform type="linkrewritter" src="cocoon:/linkmap"> <!-- the
links are transformed -->
      <map:parameter name="namespace-uri" value="
http://www.w3.org/1999/xhtml"/>
    </map:transform>
    <map:serialize type="xml"/>
  </map:match>

...
</map:pipeline>



>
> Thanks so much for your help.
>
> - Bob
>
>
> On Wed, May 16, 2012 at 10:24 AM, Bob Harrod <rj...@gmail.com> wrote:
>
>> I'm rending html in a transform, and would like to render an anchor who's
>> href is absolute, not relative.  For example, instead of this:
>>
>> <a href="../home">...</a>
>>
>> I would like to be able to provide a full url in the href:
>>
>> <a href="http://mysite/application1/home">...</a>
>>
>> Thank you for your assistance with this!
>>
>>
>> On Wed, May 16, 2012 at 12:52 AM, Bob Harrod <rj...@gmail.com> wrote:
>>
>>> I'm quite new to cocoon, and supporting an older version (2.1).  Does
>>> anyone know how I can gain access the web application base path inside of a
>>> transform?  Of course, it can be passed by the sitemap...  Any help would
>>> be appreciated!
>>>
>>> Thanks!
>>>
>>
>>
>

Re: Cocoon 2.1 web application base path

Posted by Bob Harrod <rj...@gmail.com>.
Including {request.contextPath} as a transform param did the trick, thanks!

Is there any way to do this globally for all matches in the sitemap or does
it have to be passed to each transform?

- Bob
On May 16, 2012 12:53 PM, "Bob Harrod" <rj...@gmail.com> wrote:

> Ok, thank you!  I can look at the LinkRewriterTransformer.  Since I'm new
> to this, I have some follow up questions:
>
> 1. Is this a "plugin" that I have to install or does it exist in the stock
> version of cocoon 2.1?
>
> 2. The examples reference the transformer from a sitemap context.  Is
> there a way to use the LinkRewriterTranformer directly from another
> transform (as this transform is actually creating the anchor)?
>
> Thanks so much for your help.
>
> - Bob
>
>
> On Wed, May 16, 2012 at 10:24 AM, Bob Harrod <rj...@gmail.com> wrote:
>
>> I'm rending html in a transform, and would like to render an anchor who's
>> href is absolute, not relative.  For example, instead of this:
>>
>> <a href="../home">...</a>
>>
>> I would like to be able to provide a full url in the href:
>>
>> <a href="http://mysite/application1/home">...</a>
>>
>> Thank you for your assistance with this!
>>
>>
>> On Wed, May 16, 2012 at 12:52 AM, Bob Harrod <rj...@gmail.com> wrote:
>>
>>> I'm quite new to cocoon, and supporting an older version (2.1).  Does
>>> anyone know how I can gain access the web application base path inside of a
>>> transform?  Of course, it can be passed by the sitemap...  Any help would
>>> be appreciated!
>>>
>>> Thanks!
>>>
>>
>>
>

Re: Cocoon 2.1 web application base path

Posted by Bob Harrod <rj...@gmail.com>.
Ok, thank you!  I can look at the LinkRewriterTransformer.  Since I'm new
to this, I have some follow up questions:

1. Is this a "plugin" that I have to install or does it exist in the stock
version of cocoon 2.1?

2. The examples reference the transformer from a sitemap context.  Is there
a way to use the LinkRewriterTranformer directly from another transform (as
this transform is actually creating the anchor)?

Thanks so much for your help.

- Bob


On Wed, May 16, 2012 at 10:24 AM, Bob Harrod <rj...@gmail.com> wrote:

> I'm rending html in a transform, and would like to render an anchor who's
> href is absolute, not relative.  For example, instead of this:
>
> <a href="../home">...</a>
>
> I would like to be able to provide a full url in the href:
>
> <a href="http://mysite/application1/home">...</a>
>
> Thank you for your assistance with this!
>
>
> On Wed, May 16, 2012 at 12:52 AM, Bob Harrod <rj...@gmail.com> wrote:
>
>> I'm quite new to cocoon, and supporting an older version (2.1).  Does
>> anyone know how I can gain access the web application base path inside of a
>> transform?  Of course, it can be passed by the sitemap...  Any help would
>> be appreciated!
>>
>> Thanks!
>>
>
>

Re: Cocoon 2.1 web application base path

Posted by Javier Puerto <jp...@gmail.com>.
Hi Bob

2012/5/16 Bob Harrod <rj...@gmail.com>

> I'm rending html in a transform, and would like to render an anchor who's
> href is absolute, not relative.  For example, instead of this:
>
> <a href="../home">...</a>
>
> I would like to be able to provide a full url in the href:
>
> <a href="http://mysite/application1/home">...</a>
>
> Thank you for your assistance with this!
>

I think that you want to use the LinkRewriterTransformer

http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/transformation/LinkRewriterTransformer.html

I hope that it's helps.

Salu2.


>
> On Wed, May 16, 2012 at 12:52 AM, Bob Harrod <rj...@gmail.com> wrote:
>
>> I'm quite new to cocoon, and supporting an older version (2.1).  Does
>> anyone know how I can gain access the web application base path inside of a
>> transform?  Of course, it can be passed by the sitemap...  Any help would
>> be appreciated!
>>
>> Thanks!
>>
>
>

Re: Cocoon 2.1 web application base path

Posted by Bob Harrod <rj...@gmail.com>.
I'm rending html in a transform, and would like to render an anchor who's
href is absolute, not relative.  For example, instead of this:

<a href="../home">...</a>

I would like to be able to provide a full url in the href:

<a href="http://mysite/application1/home">...</a>

Thank you for your assistance with this!


On Wed, May 16, 2012 at 12:52 AM, Bob Harrod <rj...@gmail.com> wrote:

> I'm quite new to cocoon, and supporting an older version (2.1).  Does
> anyone know how I can gain access the web application base path inside of a
> transform?  Of course, it can be passed by the sitemap...  Any help would
> be appreciated!
>
> Thanks!
>

Re: Cocoon 2.1 web application base path

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andy,

On 5/16/12 12:36 PM, Andy Stevens wrote:
> Hi Bob,
> 
> Assuming you have the request input module in your cocoon.xconf,
> then you can pass the context path into an xsl:param (or otherwise
> use in the sitemap) with e.g. <map:transform
> src="mytransform.xslt"> <map:parameter="xslParamName"
> ="{request:contextPath}"/> </map:transform>

+1

IMO this is the right way to do things.

If you want a completely, fully-absolute URL, you might want to:

 <map:parameter name="requestScheme" value="{request:scheme}" />
 <map:parameter name="requestServerName" value="{request:serverName}" />
 <map:parameter name="requestServerPort" value="{request:serverPort}" />

 <map:parameter name="context-path" value="{request:contextPath}" />
 <map:parameter name="request-uri" value="{request:requestURI}" />
 <map:parameter name="query-string" value="{request:queryString}" />

We have a bunch of XSL templates that produce XHTML and need to
provide references back to themselves in certain circumstances. So, we
pass everything and the template can build as much of the URL as it
chooses in a case-by-case basis.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+1IRUACgkQ9CaO5/Lv0PCCZQCgqewzX0xNnTU4rPzeccS2tadN
AwYAn3xRtJ2ZpXOHU8tg2IJLD1BAq87m
=9G3l
-----END PGP SIGNATURE-----

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


Re: Cocoon 2.1 web application base path

Posted by Andy Stevens <in...@googlemail.com>.
Hi Bob,

Assuming you have the request input module in your cocoon.xconf, then you
can pass the context path into an xsl:param (or otherwise use in the
sitemap) with e.g.
<map:transform src="mytransform.xslt">
<map:parameter="xslParamName" ="{request:contextPath}"/>
</map:transform>

Regards,

Andy
 On 16 May 2012 06:02, "Bob Harrod" <rj...@gmail.com> wrote:

> I'm quite new to cocoon, and supporting an older version (2.1).  Does
> anyone know how I can gain access the web application base path inside of a
> transform?  Of course, it can be passed by the sitemap...  Any help would
> be appreciated!
>
> Thanks!
>

Re: Cocoon 2.1 web application base path

Posted by Jos Snellings <jo...@upperware.biz>.
Hi !

What are you trying to achieve?

Jos

On Wed, May 16, 2012 at 6:52 AM, Bob Harrod <rj...@gmail.com> wrote:

> I'm quite new to cocoon, and supporting an older version (2.1).  Does
> anyone know how I can gain access the web application base path inside of a
> transform?  Of course, it can be passed by the sitemap...  Any help would
> be appreciated!
>
> Thanks!
>



-- 
The doctrine of human equality reposes on this: that there is no man
really clever who has not found that he is stupid.
        -- Gilbert K. Chesterson