You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Cyril Vidal <cy...@planetexml.com> on 2003/01/25 13:52:26 UTC

simple question about RequestSelector

Dear all,

I would like to process an URI of the following type:
http://localhost:8080/cocoon/hellococoon?langue=anglais&critere=organisme

The first parameter's role is to select a specified stylesheet:
langue=anglais -> select participantsEN.xslt
langue=francais -> select participantsFR.xslt

while parameter 'critere' is used to pass a parameter to the selectionned
stylesheet.

If I only take care about the parameter 'langue', the following code's
snippet using RequestSelector works fine:
<map:match pattern="">


<map:generate src="documents/participants.xml"/>

<map:select type="request">

<map:parameter name="parameter-name" value="langue"/>

<map:when test="francais">

<map:transform src="stylesheets/participantsFR.xsl">

</map:transform>

</map:when>

<map:when test="anglais">

<map:transform src="stylesheets/participantsEN.xsl"/>

</map:when>

<map:otherwise>

<map:transform src="stylesheets/participantsFR.xsl"/>

</map:otherwise>

</map:select>

<map:serialize type="html"/>

</map:match>



But When I want to deal with the second parameter too, (by adding the
following instructions):



<map:parameter name="use-request-parameters" value="true"/>

<map:parameter name="tri" value="{critere}"/>



 I have some problems, indeed I receive no error messag but nothing is
happening.

I use the the following code:



<map:match pattern="">


<map:generate src="documents/participants.xml"/>

<map:select type="request">

<map:parameter name="parameter-name" value="langue"/>

<map:when test="francais">

<map:transform src="stylesheets/participantsFR.xsl">

<map:parameter name="use-request-parameters" value="true"/>

<map:parameter name="tri" value="{critere}"/>

</map:transform>

</map:when>

...

</map:match>

</map:when>

I'm sure the XSLT works well , so I guess the sitemap' syntax ins't good.

Can someone help me, please?

Thannks in advance,

Cyril.


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simple question about RequestSelector

Posted by Konstantin Piroumian <kp...@apache.org>.
From: "Cyril Vidal" <cy...@planetexml.com>

<snip/>
>
> Now, I will try to do something with i18nTransformer, so that I shouldn't
> need no more two stylesheets.
>
> If you know some accessible documentation about it, I would be very
> intersted in...

Start from here:
http://xml.apache.org/cocoon/userdocs/transformers/i18n-transformer.html

and then take a look at i18n samples in /src/webapp/samples/i18n/

--
  Konstantin

>
> Any way , Again Many Thanks, for your Help,
>
> Best,
>
> Cyril.
>
> ----- Original Message -----
> From: "Joerg Heinicke" <jo...@gmx.de>
> To: <co...@xml.apache.org>
> Sent: Saturday, January 25, 2003 4:42 PM
> Subject: Re: simple question about RequestSelector
>
>
> > Hello Cyril,
> >
> > the participants.xsl can be really simple:
> >
> > <xsl:stylesheet version="1.0" xmlns:xsl="..">
> >
> > <xsl:include href="participantsYOURDEFAULTLANGUAGE.xsl"/>
> >
> > </xsl:stylesheet>
> >
> > Replacing YOURDEFAULTLANGUAGE with EN or FR you can choose the default
> > language of the application. And the above stylesheet is really not
> > difficult to maintain.
> >
> > But maybe there is such a fallback operation in the input modules too?
> >
> > Regards,
> >
> > Joerg
> >
> > Cyril Vidal wrote:
> > > Hi Christian,
> > >
> > > Thanks again very much for your help.
> > > I've tested what you suggested me (a good idea...) and it works fine:
> > >
> > > But, as I read in Cocoon center's lesson about request parameter:
> > > Some advantages of RequestSelector over a RequestParamAction are that
> > >
> > >          you can use a default stylesheet when the parameter is not
> present,
> > >
> > >
> > > and in my example, when I point the browser for the first time to
> > > http://localhost:8080/cocoon/hellococoon
> > >
> > > of course, because I not have participants.xsl among my stylesheets
but
> > > juste participantsFR.xsl and particpantsEN.xsl,  Cocoon generates an
> > > error...(In fact, I've added another particpants.xsl styleshhet to fix
> the
> > > problem, but it also requires to build another stylesheet...). Or is
> there
> > > another simplest solution?
> > >
> > >
> > >>Regarding the original question, I believe the
"use-request-parameters"
> > >>configuration needs to go into the configuration section and not into
> > >>the pipeline.
> > >
> > >
> > > IN the same lesson, it's said apparently that we can:
> > >
>
http://www.cocooncenter.de/cc/documents/resources/request-params/transformer
> > > .html
> > > I've tested it in another example and it seemed to work.
> > >
> > >  In addition, you would not neet the next
> > >
> > >>  <map:parameter name="tri" value="{critere}"/>
> > >>becasue *all* parameters are available. Besides, "{critere}" is
> > >>undefined at this place since the selector does not set any sitemap
> > >>variables. For this you would need either the input module syntax
above
> > >>or an action that sets a variable.
> > >>
> > >
> > >
> > > ...I'm sorry, but I'm afraid not to understand very well what you're
> trying
> > > to explain to me...
> > > How can I mix an action and a select?
> > >
> > > Thanks for your help,
> > > Best,
> > > Cyril.
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question  has not already been answered in the
> > FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail:     <co...@xml.apache.org>
> > For additional commands, e-mail:   <co...@xml.apache.org>
> >
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
>
>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simple question about RequestSelector

Posted by Cyril Vidal <cy...@planetexml.com>.
Thanks to all for your help!
It's working now, with two different methods:

1°) Using a RequestParamAction:
<map:act type="request">

<map:parameter name="parameters" value="true"/>

<map:generate src="documents/participants.xml"/>

<map:transform src="stylesheets/participants{langue}.xsl">

<map:parameter name="use-request-parameters" value="true"/>

<map:parameter name="tri" value="{critere}"/>

</map:transform>

</map:act>

and by editing a default participants.xslt file, as described by Joerg.

2°) Using a RequestSelector:

<map:generate src="documents/participants.xml"/>

<map:select type="request">

<map:parameter name="parameter-name" value="langue"/>

<map:when test="francais">

<map:transform type="xslt-with-parameters"

src="stylesheets/participantsFR.xsl">

</map:transform>

</map:when>

<map:when test="anglais">

<map:transform type="xslt-with-parameters"

src="stylesheets/participantsEN.xsl"/>

<map:parameter name="use-request-parameters" value="true"/>

</map:when>

<map:otherwise>

<map:transform type="xslt-with-parameters"

src="stylesheets/participantsFR.xsl"/>

</map:otherwise>

</map:select>

<map:serialize type="html"/>



with transformer component 'xslt-with-parameters' defined as below:

<map:transformer name="xslt-with-parameters"
src="org.apache.cocoon.transformation.TraxTransformer">

<use-request-parameters>true</use-request-parameters>

</map:transformer>



Now, I will try to do something with i18nTransformer, so that I shouldn't
need no more two stylesheets.

If you know some accessible documentation about it, I would be very
intersted in...

Any way , Again Many Thanks, for your Help,

Best,

Cyril.

----- Original Message -----
From: "Joerg Heinicke" <jo...@gmx.de>
To: <co...@xml.apache.org>
Sent: Saturday, January 25, 2003 4:42 PM
Subject: Re: simple question about RequestSelector


> Hello Cyril,
>
> the participants.xsl can be really simple:
>
> <xsl:stylesheet version="1.0" xmlns:xsl="..">
>
> <xsl:include href="participantsYOURDEFAULTLANGUAGE.xsl"/>
>
> </xsl:stylesheet>
>
> Replacing YOURDEFAULTLANGUAGE with EN or FR you can choose the default
> language of the application. And the above stylesheet is really not
> difficult to maintain.
>
> But maybe there is such a fallback operation in the input modules too?
>
> Regards,
>
> Joerg
>
> Cyril Vidal wrote:
> > Hi Christian,
> >
> > Thanks again very much for your help.
> > I've tested what you suggested me (a good idea...) and it works fine:
> >
> > But, as I read in Cocoon center's lesson about request parameter:
> > Some advantages of RequestSelector over a RequestParamAction are that
> >
> >          you can use a default stylesheet when the parameter is not
present,
> >
> >
> > and in my example, when I point the browser for the first time to
> > http://localhost:8080/cocoon/hellococoon
> >
> > of course, because I not have participants.xsl among my stylesheets but
> > juste participantsFR.xsl and particpantsEN.xsl,  Cocoon generates an
> > error...(In fact, I've added another particpants.xsl styleshhet to fix
the
> > problem, but it also requires to build another stylesheet...). Or is
there
> > another simplest solution?
> >
> >
> >>Regarding the original question, I believe the "use-request-parameters"
> >>configuration needs to go into the configuration section and not into
> >>the pipeline.
> >
> >
> > IN the same lesson, it's said apparently that we can:
> >
http://www.cocooncenter.de/cc/documents/resources/request-params/transformer
> > .html
> > I've tested it in another example and it seemed to work.
> >
> >  In addition, you would not neet the next
> >
> >>  <map:parameter name="tri" value="{critere}"/>
> >>becasue *all* parameters are available. Besides, "{critere}" is
> >>undefined at this place since the selector does not set any sitemap
> >>variables. For this you would need either the input module syntax above
> >>or an action that sets a variable.
> >>
> >
> >
> > ...I'm sorry, but I'm afraid not to understand very well what you're
trying
> > to explain to me...
> > How can I mix an action and a select?
> >
> > Thanks for your help,
> > Best,
> > Cyril.
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simple question about RequestSelector

Posted by Christian Haul <ha...@informatik.tu-darmstadt.de>.
Joerg Heinicke wrote:
> Hello Cyril,
> 
> the participants.xsl can be really simple:
> 
> <xsl:stylesheet version="1.0" xmlns:xsl="..">
> 
> <xsl:include href="participantsYOURDEFAULTLANGUAGE.xsl"/>
> 
> </xsl:stylesheet>
> 
> Replacing YOURDEFAULTLANGUAGE with EN or FR you can choose the default 
> language of the application. And the above stylesheet is really not 
> difficult to maintain.
> 
> But maybe there is such a fallback operation in the input modules too?

Indeed there is. But that get a little bit more complex since one would 
need to put several of them together in cocoon.xconf. I.e. (from 2.1 
cocoon.xconf)

     <component-instance logger="core.modules.input" name="chain" 
class="org.apache.cocoon.components.modules.input.ChainMetaModule">
       <input-module name="request-param"/>
       <input-module name="request-attr"/>
       <input-module name="session-attr"/>
       <input-module name="defaults"/>
     </component-instance>

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
     fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simple question about RequestSelector

Posted by Joerg Heinicke <jo...@gmx.de>.
Hello Cyril,

the participants.xsl can be really simple:

<xsl:stylesheet version="1.0" xmlns:xsl="..">

<xsl:include href="participantsYOURDEFAULTLANGUAGE.xsl"/>

</xsl:stylesheet>

Replacing YOURDEFAULTLANGUAGE with EN or FR you can choose the default 
language of the application. And the above stylesheet is really not 
difficult to maintain.

But maybe there is such a fallback operation in the input modules too?

Regards,

Joerg

Cyril Vidal wrote:
> Hi Christian,
> 
> Thanks again very much for your help.
> I've tested what you suggested me (a good idea...) and it works fine:
> 
> But, as I read in Cocoon center's lesson about request parameter:
> Some advantages of RequestSelector over a RequestParamAction are that
> 
>          you can use a default stylesheet when the parameter is not present,
> 
> 
> and in my example, when I point the browser for the first time to
> http://localhost:8080/cocoon/hellococoon
> 
> of course, because I not have participants.xsl among my stylesheets but
> juste participantsFR.xsl and particpantsEN.xsl,  Cocoon generates an
> error...(In fact, I've added another particpants.xsl styleshhet to fix the
> problem, but it also requires to build another stylesheet...). Or is there
> another simplest solution?
> 
> 
>>Regarding the original question, I believe the "use-request-parameters"
>>configuration needs to go into the configuration section and not into
>>the pipeline.
> 
> 
> IN the same lesson, it's said apparently that we can:
> http://www.cocooncenter.de/cc/documents/resources/request-params/transformer
> .html
> I've tested it in another example and it seemed to work.
> 
>  In addition, you would not neet the next
> 
>>  <map:parameter name="tri" value="{critere}"/>
>>becasue *all* parameters are available. Besides, "{critere}" is
>>undefined at this place since the selector does not set any sitemap
>>variables. For this you would need either the input module syntax above
>>or an action that sets a variable.
>>
> 
> 
> ...I'm sorry, but I'm afraid not to understand very well what you're trying
> to explain to me...
> How can I mix an action and a select?
> 
> Thanks for your help,
> Best,
> Cyril.


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simple question about RequestSelector

Posted by Cyril Vidal <cy...@planetexml.com>.
Hi Christian,

Thanks again very much for your help.
I've tested what you suggested me (a good idea...) and it works fine:

But, as I read in Cocoon center's lesson about request parameter:
Some advantages of RequestSelector over a RequestParamAction are that

         you can use a default stylesheet when the parameter is not present,


and in my example, when I point the browser for the first time to
http://localhost:8080/cocoon/hellococoon

of course, because I not have participants.xsl among my stylesheets but
juste participantsFR.xsl and particpantsEN.xsl,  Cocoon generates an
error...(In fact, I've added another particpants.xsl styleshhet to fix the
problem, but it also requires to build another stylesheet...). Or is there
another simplest solution?

> Regarding the original question, I believe the "use-request-parameters"
> configuration needs to go into the configuration section and not into
> the pipeline.

IN the same lesson, it's said apparently that we can:
http://www.cocooncenter.de/cc/documents/resources/request-params/transformer
.html
I've tested it in another example and it seemed to work.

 In addition, you would not neet the next
>   <map:parameter name="tri" value="{critere}"/>
> becasue *all* parameters are available. Besides, "{critere}" is
> undefined at this place since the selector does not set any sitemap
> variables. For this you would need either the input module syntax above
> or an action that sets a variable.
>

...I'm sorry, but I'm afraid not to understand very well what you're trying
to explain to me...
How can I mix an action and a select?

Thanks for your help,
Best,
Cyril.

Re: simple question about RequestSelector

Posted by Christian Haul <ha...@informatik.tu-darmstadt.de>.
Cyril Vidal wrote:
> Dear all,
> 
> I would like to process an URI of the following type:
> http://localhost:8080/cocoon/hellococoon?langue=anglais&critere=organisme
> 
> The first parameter's role is to select a specified stylesheet:
> langue=anglais -> select participantsEN.xslt
> langue=francais -> select participantsFR.xslt
> 
> while parameter 'critere' is used to pass a parameter to the selectionned
> stylesheet.

While this is no answer to your question, it might still be helpful.
Say you are using at least 2.0.4 and are able to either rename your xsl 
or the parameter value so that they match. Then you could do

   <map:match pattern="">
     <map:generate src="documents/participants.xml"/>
     <map:transform 
src="stylesheets/participants{request-param:language}.xsl">
        <map:parameter name="tri" value="{request-param:critere}"/>
     </map:transform>
     <map:serialize type="html"/>
   </map:match>

The so called input modules are available like any other variable from 
the sitemap.

Regarding the original question, I believe the "use-request-parameters" 
configuration needs to go into the configuration section and not into 
the pipeline. In addition, you would not neet the next
  <map:parameter name="tri" value="{critere}"/>
becasue *all* parameters are available. Besides, "{critere}" is 
undefined at this place since the selector does not set any sitemap 
variables. For this you would need either the input module syntax above 
or an action that sets a variable.

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
     fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


AW: simple question about RequestSelector

Posted by Marco Rolappe <m_...@web.de>.
hi cyril,

the problem is the '{critere}'. you have no sitemap component creating this
sitemap variable. but in this case you don't need that anyway since you are
instructing the XSLT-/TraxTransformer to 'use-request-parameters', i.e. make
all request parameters available to the stylesheet as stylesheet params. to
be able to access 'critere' within the stylesheet then, declare it at the
head of your stylesheet (<xsl:param name="critere"/>). should you need the
parameter to be named 'tri', the simple solution would be a <xsl:param
name="tri" select="$critere"/>.

HTH

-----Ursprüngliche Nachricht-----
Von: cocoon-users-return-45301-m_rolappe=web.de@xml.apache.org
[mailto:cocoon-users-return-45301-m_rolappe=web.de@xml.apache.org]Im
Auftrag von Cyril Vidal
Gesendet: Samstag, 25. Januar 2003 13:52
An: cocoon-users@xml.apache.org
Betreff: simple question about RequestSelector


Dear all,

I would like to process an URI of the following type:
http://localhost:8080/cocoon/hellococoon?langue=anglais&critere=organisme

The first parameter's role is to select a specified stylesheet:
langue=anglais -> select participantsEN.xslt
langue=francais -> select participantsFR.xslt

while parameter 'critere' is used to pass a parameter to the selectionned
stylesheet.

If I only take care about the parameter 'langue', the following code's
snippet using RequestSelector works fine:
<map:match pattern="">


<map:generate src="documents/participants.xml"/>

<map:select type="request">

<map:parameter name="parameter-name" value="langue"/>

<map:when test="francais">

<map:transform src="stylesheets/participantsFR.xsl">

</map:transform>

</map:when>

<map:when test="anglais">

<map:transform src="stylesheets/participantsEN.xsl"/>

</map:when>

<map:otherwise>

<map:transform src="stylesheets/participantsFR.xsl"/>

</map:otherwise>

</map:select>

<map:serialize type="html"/>

</map:match>



But When I want to deal with the second parameter too, (by adding the
following instructions):



<map:parameter name="use-request-parameters" value="true"/>

<map:parameter name="tri" value="{critere}"/>



 I have some problems, indeed I receive no error messag but nothing is
happening.

I use the the following code:



<map:match pattern="">


<map:generate src="documents/participants.xml"/>

<map:select type="request">

<map:parameter name="parameter-name" value="langue"/>

<map:when test="francais">

<map:transform src="stylesheets/participantsFR.xsl">

<map:parameter name="use-request-parameters" value="true"/>

<map:parameter name="tri" value="{critere}"/>

</map:transform>

</map:when>

...

</map:match>

</map:when>

I'm sure the XSLT works well , so I guess the sitemap' syntax ins't good.

Can someone help me, please?

Thannks in advance,

Cyril.


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>