You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by O....@sh.cvut.cz on 2003/12/29 02:25:39 UTC

how to put {1}, {2}... into XSP

Hi, I have a this problem. I'd like to put parsed pieces of URI into 
serverpages as parameters. For example: I have URI "html/english/article/102" 
(it means, that I want to get article with ID=102 in english language and in 
HTML format). Sitemap could look like as 

<map:match pattern="*/*/*/*">
  <map:generate type="serverpages" src="logic/{3}.xsp">
    <map:parameter name="format" value="{1}"/>
    <map:parameter name="language" value="{2}"/>
    <map:parameter name="id" value="{4}"/>
  </map:generate>
  <map:transform src="stylesheets/{3}to{1}.xsl"/>
  <map:serialize type="{1}"/>
</map:match>

I know, that <map:parameter> tag is nonsense, but how to get the pieces of URI 
{1}, {2}... into serverpages? (and how to read them in xsp script?). Yes, 
needed informations could be theoretically obtained by parsing URI in xsp 
script, but in this case will be not URL scheme transparent to scripts. (I can 
decide in the future, that URI will be not "html/english/article/102" but for 
example "english/html/article/102" - and then I will have to rewrite all the 
xsp scripts).

Is any possibility, how to do it?

PS. Another problem is in the tag <map:serialize type="{1}"/> - there is not 
substituted {1}.


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


Re: how to put {1}, {2}... into XSP

Posted by Joerg Heinicke <jo...@gmx.de>.

On 29.12.2003 02:25, O.Vobejda@sh.cvut.cz wrote:

> Hi, I have a this problem. I'd like to put parsed pieces of URI into 
> serverpages as parameters. For example: I have URI "html/english/article/102" 
> (it means, that I want to get article with ID=102 in english language and in 
> HTML format). Sitemap could look like as 
> 
> <map:match pattern="*/*/*/*">
>   <map:generate type="serverpages" src="logic/{3}.xsp">
>     <map:parameter name="format" value="{1}"/>
>     <map:parameter name="language" value="{2}"/>
>     <map:parameter name="id" value="{4}"/>
>   </map:generate>
>   <map:transform src="stylesheets/{3}to{1}.xsl"/>
>   <map:serialize type="{1}"/>
> </map:match>
> 
> I know, that <map:parameter> tag is nonsense, but how to get the pieces of URI 
> {1}, {2}... into serverpages? (and how to read them in xsp script?). Yes, 
> needed informations could be theoretically obtained by parsing URI in xsp 
> script, but in this case will be not URL scheme transparent to scripts. (I can 
> decide in the future, that URI will be not "html/english/article/102" but for 
> example "english/html/article/102" - and then I will have to rewrite all the 
> xsp scripts).

Why should this be nonsense? It's the way to go ...

> PS. Another problem is in the tag <map:serialize type="{1}"/> - there is not 
> substituted {1}.

Yes, this won't work. You have to use a selector.

<map:select type="Idontknow">
   <map:when test="xml">
     <map:serialize type="xml"/>
   </map:when>
   <map:otherwise>
     <map:serialize type="html"/>
   </map:otherwise>
</map:select>

Joerg


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


Re: how to put {1}, {2}... into XSP

Posted by Simon Mieth <si...@t-online.de>.
On Mon, 29 Dec 2003 02:25:39 +0100
O.Vobejda@sh.cvut.cz wrote:

> Hi, I have a this problem. I'd like to put parsed pieces
> of URI into serverpages as parameters. For example: I have
> URI "html/english/article/102" (it means, that I want to
> get article with ID=102 in english language and in HTML
> format). Sitemap could look like as 
> 
> <map:match pattern="*/*/*/*">
>   <map:generate type="serverpages" src="logic/{3}.xsp">
>     <map:parameter name="format" value="{1}"/>
>     <map:parameter name="language" value="{2}"/>
>     <map:parameter name="id" value="{4}"/>
>   </map:generate>
>   <map:transform src="stylesheets/{3}to{1}.xsl"/>
>   <map:serialize type="{1}"/>
> </map:match>
> 
> I know, that <map:parameter> tag is nonsense, but how to
> get the pieces of URI {1}, {2}... into serverpages? (and
> how to read them in xsp script?). Yes, needed informations
> could be theoretically obtained by parsing URI in xsp
> script, but in this case will be not URL scheme
> transparent to scripts. (I can decide in the future, that
> URI will be not "html/english/article/102" but for example
> "english/html/article/102" - and then I will have to
> rewrite all the xsp scripts).

Hi,

have not tried this, but found it in the mail-archiv


<xsp:logic>
String format =
this.parameters.getParameter("format");

// and all other parameters

</xsp:logic>

this works, becouse all XSP's are Generators.



Regards Simon




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


Re: how to put {1}, {2}... into XSP

Posted by O....@sh.cvut.cz.
Thanks for your answer, but I think, that it would be better non-use parameters 
in URL (at most for subsidiary reasons), because of easy generating offline 
version of the web. That's why I want to use this type of URL (for example 
http://domain/html/en/article/10) as I wrote before.

Otmar Vobejda


Cituji z emailu od Ralph Seidl <R....@ff-muenchen.de>:

> Hi O.Vobejda,
> 
> I don't have an answer to your question, but have you considered doing 
> something like this:
> 
> URL: article.html?id=102&lang=english
> or   article.pdf?id=102&lang=english
> 
> Sitemap:
> <map:match pattern="*.html">
>    <map:act type="Dispatcher" src="{0}">
>      <map:generate type="serverpages" src="logic/{xspPage}"/>
>      <map:transform src="stylesheets/{xslPage}"/>
>      <map:serialize type="html"/>
>    </map:act>
> </map:match>
> <map:match pattern="*.xml">
>    <map:act type="Dispatcher" src="{0}">
>      <map:generate type="serverpages" src="logic/{xspPage}"/>
>      <map:transform src="stylesheets/{xslPage}"/>
>      <map:serialize type="xml"/>
>    </map:act>
> </map:match>
> <map:match pattern="*.pdf">
>    <map:act type="Dispatcher" src="{0}">
>      <map:generate type="serverpages" src="logic/{xspPage}"/>
>      <map:transform src="stylesheets/{xslPage}"/>
>      <map:serialize type="pdf"/>
>    </map:act>
> </map:match>
> 
> So you need a dispatcher-action which delivers the values for {xspPage} 
> and {xslPage}. (Writing an action is simple :-) )
> In the action and in the XSP-page you can access 'id' and 'lang' as 
> request-parameters.
> 
> Hope this helps,
> 
> Ralph
> 
> PS: You can even do this: 
> foo.html?id=102&lang=english&page=article&type=html
> 
> O.Vobejda@sh.cvut.cz wrote:
> > Hi, I have a this problem. I'd like to put parsed pieces of URI into 
> > serverpages as parameters. For example: I have URI
> "html/english/article/102" 
> > (it means, that I want to get article with ID=102 in english language and
> in 
> > HTML format). Sitemap could look like as 
> > 
> > <map:match pattern="*/*/*/*">
> >   <map:generate type="serverpages" src="logic/{3}.xsp">
> >     <map:parameter name="format" value="{1}"/>
> >     <map:parameter name="language" value="{2}"/>
> >     <map:parameter name="id" value="{4}"/>
> >   </map:generate>
> >   <map:transform src="stylesheets/{3}to{1}.xsl"/>
> >   <map:serialize type="{1}"/>
> > </map:match>
> > 
> > I know, that <map:parameter> tag is nonsense, but how to get the pieces of
> URI 
> > {1}, {2}... into serverpages? (and how to read them in xsp script?). Yes,
> 
> > needed informations could be theoretically obtained by parsing URI in xsp
> 
> > script, but in this case will be not URL scheme transparent to scripts. (I
> can 
> > decide in the future, that URI will be not "html/english/article/102" but
> for 
> > example "english/html/article/102" - and then I will have to rewrite all
> the 
> > xsp scripts).
> > 
> > Is any possibility, how to do it?
> > 
> > PS. Another problem is in the tag <map:serialize type="{1}"/> - there is
> not 
> > substituted {1}.
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 




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


Re: how to put {1}, {2}... into XSP

Posted by Ralph Seidl <R....@ff-muenchen.de>.
Hi O.Vobejda,

I don't have an answer to your question, but have you considered doing 
something like this:

URL: article.html?id=102&lang=english
or   article.pdf?id=102&lang=english

Sitemap:
<map:match pattern="*.html">
   <map:act type="Dispatcher" src="{0}">
     <map:generate type="serverpages" src="logic/{xspPage}"/>
     <map:transform src="stylesheets/{xslPage}"/>
     <map:serialize type="html"/>
   </map:act>
</map:match>
<map:match pattern="*.xml">
   <map:act type="Dispatcher" src="{0}">
     <map:generate type="serverpages" src="logic/{xspPage}"/>
     <map:transform src="stylesheets/{xslPage}"/>
     <map:serialize type="xml"/>
   </map:act>
</map:match>
<map:match pattern="*.pdf">
   <map:act type="Dispatcher" src="{0}">
     <map:generate type="serverpages" src="logic/{xspPage}"/>
     <map:transform src="stylesheets/{xslPage}"/>
     <map:serialize type="pdf"/>
   </map:act>
</map:match>

So you need a dispatcher-action which delivers the values for {xspPage} 
and {xslPage}. (Writing an action is simple :-) )
In the action and in the XSP-page you can access 'id' and 'lang' as 
request-parameters.

Hope this helps,

Ralph

PS: You can even do this: 
foo.html?id=102&lang=english&page=article&type=html

O.Vobejda@sh.cvut.cz wrote:
> Hi, I have a this problem. I'd like to put parsed pieces of URI into 
> serverpages as parameters. For example: I have URI "html/english/article/102" 
> (it means, that I want to get article with ID=102 in english language and in 
> HTML format). Sitemap could look like as 
> 
> <map:match pattern="*/*/*/*">
>   <map:generate type="serverpages" src="logic/{3}.xsp">
>     <map:parameter name="format" value="{1}"/>
>     <map:parameter name="language" value="{2}"/>
>     <map:parameter name="id" value="{4}"/>
>   </map:generate>
>   <map:transform src="stylesheets/{3}to{1}.xsl"/>
>   <map:serialize type="{1}"/>
> </map:match>
> 
> I know, that <map:parameter> tag is nonsense, but how to get the pieces of URI 
> {1}, {2}... into serverpages? (and how to read them in xsp script?). Yes, 
> needed informations could be theoretically obtained by parsing URI in xsp 
> script, but in this case will be not URL scheme transparent to scripts. (I can 
> decide in the future, that URI will be not "html/english/article/102" but for 
> example "english/html/article/102" - and then I will have to rewrite all the 
> xsp scripts).
> 
> Is any possibility, how to do it?
> 
> PS. Another problem is in the tag <map:serialize type="{1}"/> - there is not 
> substituted {1}.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


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