You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Anna Afonchenko <an...@ubaccess.com> on 2002/12/17 12:55:19 UTC

value-substitution in Cocoon

I have the following question:
I know that in Cocoon I can use value substitution inside a pipeline, e.g. if I have a pipeline
<map:pipeline>
  <map:match pattern="*/*.html">
    <map:generate src="{2}.html"/>
    <map:transform src="some.xsl">
      <map:parameter name="param" value="{1}"/>
    </map:transform>
  </map:match>
</map:pipeline>

and if I write the URI http://localhost:8080/cocoon/param1/some.html

then in the pipeline the stylesheet some.xsl will receive a parameter with name param and value param1. So this is my question:
Can I somehow parse/evaluate this parameter {1} inside the sitemap (not inside the xsl).
E.g., can I somehow, having {1}="param1" extract the last character ("1" in this case) and send to the xsl only it, or, having parameter {1}=1, send {1}+1, i.e. 2 to the stylesheet?

I need this because I want to build pipeline that will get some parameter n, and after it is executed I want to call the same pipeline with parameter n+1.
Is this possible in sitemap?

Thank you very much for help.

Anna

Re: value-substitution in Cocoon

Posted by Konstantin Piroumian <kp...@apache.org>.
From: "Anna Afonchenko" <an...@ubaccess.com>

> Hi Konstantin.
> Thank you for answering.
> It would be very nice to have combination of input modules in sitemap
> substition values. Waiting for this to be implemented in one of the
further
> versions of Cocoon (hopefully).
> For now I will just use substring-before and substring-after to get the
> desired result.

Btw, you were saying that you need to pass 'value + 1'. Try to use XPath
syntax for that, though, I'm not sure that JXPath handles arithmetic
operations.

> One last question:
> What is the sample (samples/module) that you are talking about?
> There is no module directory under samples directory (at least in my
> distribution,
> that I downloaded just this week).
> Also, if I just print http://localhost:8080/cocoon/samples/modules (or
> module)
> I get an error of "resource not found".
> So where is this sample? I would really like to look at it.

It's currently available only in Cocoon 2.1, which in turn is available only
from CVS.
I'll try to move it to C 2.0.5 too when release date is decided.

Konstantin

>
> Thank you for your help.
>
> Anna
>
>
> ----- Original Message -----
> From: "Konstantin Piroumian" <kp...@apache.org>
> To: <co...@xml.apache.org>
> Cc: <co...@xml.apache.org>
> Sent: Wednesday, December 18, 2002 11:52 AM
> Subject: Re: value-substitution in Cocoon
>
>
> Hi Anna and Team!
>
> CC-ing this message to Cocoon Dev list, cause it raises a more general
> requirement for possibility to combine input modules with other input
> modules in sitemap substitution values (see below for a use-case).
>
> From: "Anna Afonchenko" <an...@ubaccess.com>
> To: <co...@xml.apache.org>
> Sent: Wednesday, December 18, 2002 12:23
> Subject: Re: value-substitution in Cocoon
>
>
> > Sorry for returning to this issue again, but I can't find an answer.
> > Can I use value substitutoin inside the input module?
> > Referring the example that yoou gave me, I don't want to get the
substring
> > of the whole URI, if I have match:
> > <map:match pattern="*/*.html">
>
> I see.
>
> >
> > I want to refer to the first wildcard inside the request: module,
> something
> > like:
> > <map:parameter name="param" value="{request:substring({1},0,1)}"
> > e.g. I want to apply XPath expression only on part of the URI using
value
> > substitution.
>
> Quite natural desire. Unfortunately, this is not supported (I hope yet),
but
> it would be very useful.
>
> > This is probably very stupid question, but I can't find an answer.
>
> Don't bother so much about stupid questions, if it were really stupid then
> I'd simply ignore it ;)
>
> > Can somebody please explain me this or redirect me to some URL with
> > explanations?
> > (I read the http://xml.apache.org/cocoon/userdocs/concepts/modules.html,
> but
> > it just explains the concept of modules, it doesn't have the example
that
> I
> > need).
>
> Yes, that's true. The documentation for Input module is very short, but I
> hope that the sample (/samples/modules) demonstrates most of the
> possibilities.
>
> Konstantin
>
> >
> > Thank you very much for help.
> >
> > Anna
> >
> > ----- Original Message -----
> > From: "Konstantin Piroumian" <kp...@apache.org>
> > To: <co...@xml.apache.org>
> > Sent: Tuesday, December 17, 2002 2:13 PM
> > Subject: Re: value-substitution in Cocoon
> >
> >
> > Hi!
> > (Please do not use HTML mails in the mailing list.)
> >
> > I see two ways to solve this task:
> >   1. Use an action that will get the original parameter and generate
> another
> > one, which you'll pass to the transformer.
> >   2. Use a the Request input module, e.g.  <map:parameter name="param"
> > value="{request:substring(requestURI, 0, 1)}"/> - this sample will give
> you
> > the first letter (see /samples/module/sitemap.xmap and XPath reference
to
> > learn how to get the last character).
> >
> > It sounds a little strange what you are trying to do though...
> >
> > Regards,
> >   Konstantin
> >
> > ----- Original Message -----
> > From: Anna Afonchenko
> > To: cocoon-users
> > Sent: Tuesday, December 17, 2002 14:55
> > Subject: value-substitution in Cocoon
> >
> >
> > I have the following question:
> > I know that in Cocoon I can use value substitution inside a pipeline,
e.g.
> > if I have a pipeline
> > <map:pipeline>
> >   <map:match pattern="*/*.html">
> >     <map:generate src="{2}.html"/>
> >     <map:transform src="some.xsl">
> >       <map:parameter name="param" value="{1}"/>
> >     </map:transform>
> >   </map:match>
> > </map:pipeline>
> >
> > and if I write the URI http://localhost:8080/cocoon/param1/some.html
> >
> > then in the pipeline the stylesheet some.xsl will receive a parameter
with
> > name param and value param1. So this is my question:
> > Can I somehow parse/evaluate this parameter {1} inside the sitemap (not
> > inside the xsl).
> > E.g., can I somehow, having {1}="param1" extract the last character ("1"
> in
> > this case) and send to the xsl only it, or, having parameter {1}=1, send
> > {1}+1, i.e. 2 to the stylesheet?
> >
> > I need this because I want to build pipeline that will get some
parameter
> n,
> > and after it is executed I want to call the same pipeline with parameter
> > n+1.
> > Is this possible in sitemap?
> >
> > Thank you very much for help.
> >
> > Anna
> >
> >
> > ---------------------------------------------------------------------
> > 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>
>
>
> ---------------------------------------------------------------------
> 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: value-substitution in Cocoon

Posted by Anna Afonchenko <an...@ubaccess.com>.
Hi Konstantin.
Thank you for answering.
It would be very nice to have combination of input modules in sitemap
substition values. Waiting for this to be implemented in one of the further
versions of Cocoon (hopefully).
For now I will just use substring-before and substring-after to get the
desired result.
One last question:
What is the sample (samples/module) that you are talking about?
There is no module directory under samples directory (at least in my
distribution,
that I downloaded just this week).
Also, if I just print http://localhost:8080/cocoon/samples/modules (or
module)
I get an error of "resource not found".
So where is this sample? I would really like to look at it.

Thank you for your help.

Anna


----- Original Message -----
From: "Konstantin Piroumian" <kp...@apache.org>
To: <co...@xml.apache.org>
Cc: <co...@xml.apache.org>
Sent: Wednesday, December 18, 2002 11:52 AM
Subject: Re: value-substitution in Cocoon


Hi Anna and Team!

CC-ing this message to Cocoon Dev list, cause it raises a more general
requirement for possibility to combine input modules with other input
modules in sitemap substitution values (see below for a use-case).

From: "Anna Afonchenko" <an...@ubaccess.com>
To: <co...@xml.apache.org>
Sent: Wednesday, December 18, 2002 12:23
Subject: Re: value-substitution in Cocoon


> Sorry for returning to this issue again, but I can't find an answer.
> Can I use value substitutoin inside the input module?
> Referring the example that yoou gave me, I don't want to get the substring
> of the whole URI, if I have match:
> <map:match pattern="*/*.html">

I see.

>
> I want to refer to the first wildcard inside the request: module,
something
> like:
> <map:parameter name="param" value="{request:substring({1},0,1)}"
> e.g. I want to apply XPath expression only on part of the URI using value
> substitution.

Quite natural desire. Unfortunately, this is not supported (I hope yet), but
it would be very useful.

> This is probably very stupid question, but I can't find an answer.

Don't bother so much about stupid questions, if it were really stupid then
I'd simply ignore it ;)

> Can somebody please explain me this or redirect me to some URL with
> explanations?
> (I read the http://xml.apache.org/cocoon/userdocs/concepts/modules.html,
but
> it just explains the concept of modules, it doesn't have the example that
I
> need).

Yes, that's true. The documentation for Input module is very short, but I
hope that the sample (/samples/modules) demonstrates most of the
possibilities.

Konstantin

>
> Thank you very much for help.
>
> Anna
>
> ----- Original Message -----
> From: "Konstantin Piroumian" <kp...@apache.org>
> To: <co...@xml.apache.org>
> Sent: Tuesday, December 17, 2002 2:13 PM
> Subject: Re: value-substitution in Cocoon
>
>
> Hi!
> (Please do not use HTML mails in the mailing list.)
>
> I see two ways to solve this task:
>   1. Use an action that will get the original parameter and generate
another
> one, which you'll pass to the transformer.
>   2. Use a the Request input module, e.g.  <map:parameter name="param"
> value="{request:substring(requestURI, 0, 1)}"/> - this sample will give
you
> the first letter (see /samples/module/sitemap.xmap and XPath reference to
> learn how to get the last character).
>
> It sounds a little strange what you are trying to do though...
>
> Regards,
>   Konstantin
>
> ----- Original Message -----
> From: Anna Afonchenko
> To: cocoon-users
> Sent: Tuesday, December 17, 2002 14:55
> Subject: value-substitution in Cocoon
>
>
> I have the following question:
> I know that in Cocoon I can use value substitution inside a pipeline, e.g.
> if I have a pipeline
> <map:pipeline>
>   <map:match pattern="*/*.html">
>     <map:generate src="{2}.html"/>
>     <map:transform src="some.xsl">
>       <map:parameter name="param" value="{1}"/>
>     </map:transform>
>   </map:match>
> </map:pipeline>
>
> and if I write the URI http://localhost:8080/cocoon/param1/some.html
>
> then in the pipeline the stylesheet some.xsl will receive a parameter with
> name param and value param1. So this is my question:
> Can I somehow parse/evaluate this parameter {1} inside the sitemap (not
> inside the xsl).
> E.g., can I somehow, having {1}="param1" extract the last character ("1"
in
> this case) and send to the xsl only it, or, having parameter {1}=1, send
> {1}+1, i.e. 2 to the stylesheet?
>
> I need this because I want to build pipeline that will get some parameter
n,
> and after it is executed I want to call the same pipeline with parameter
> n+1.
> Is this possible in sitemap?
>
> Thank you very much for help.
>
> Anna
>
>
> ---------------------------------------------------------------------
> 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>


---------------------------------------------------------------------
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: value-substitution in Cocoon

Posted by Tuomo L <tu...@niksula.hut.fi>.
Hi all,

I have another use-case for this kind of substitution. I'm protecting
multiple resources in my sitemap, and each resource has its own
sub-sitemap. The authentication resource produces a list of resources the
user is allowed to access. Like this:

<data>
  <resource1>true</resource2>
  <resource2>true</resource2>
  ...
</data>

These are all returned with the cocoon auth-action to the sitemap, and are
accessible with their nodenames. And here's the sitemap snippet I'd like
to use:

<map:match pattern="protected/*">
  <map:act type="auth-protect">
    <map:parameter name="handler" value="test_handler"/>

    <map:match pattern="*">
      <map:select type="parameter">
        <map:parameter name="parameter-selector-test" value="{../{1}}"/>
        <map:when test="true">
          <map:mount src="{../1}/" uri-prefix="{../1}"/>
        </map:when>
        <map:otherwise>
          <map:redirect-to uri="access_denied"/>
        </map:otherwise>
      </map:select>
    </map:match>

  </map:act>
</map:match>

So, the protected resource would be accessed with for example:
"protected/resource1". The {../{1}} in "parameter-selector-test" would
first substitute to {../resource1}, which would then become "true".
The parameter selector would now let the user pass, and the execution
would continue in the mounted sub-sitemap.

At the moment, with this functionality missing, I have to write the
snippet above for each protected resource, with only one difference in
them. Not very easy to maintain...

I hope we get this kind of parameter substition soon, it would be very
usefull, especially with the input modules combined! (And, as Konstantin
said, a quite natural desire.)

-Tuomo


On Wed, 18 Dec 2002, Konstantin Piroumian wrote:

> Hi Anna and Team!
>
> CC-ing this message to Cocoon Dev list, cause it raises a more general
> requirement for possibility to combine input modules with other input
> modules in sitemap substitution values (see below for a use-case).
>
> From: "Anna Afonchenko" <an...@ubaccess.com>
> To: <co...@xml.apache.org>
> Sent: Wednesday, December 18, 2002 12:23
> Subject: Re: value-substitution in Cocoon
>
>
> > Sorry for returning to this issue again, but I can't find an answer.
> > Can I use value substitutoin inside the input module?
> > Referring the example that yoou gave me, I don't want to get the substring
> > of the whole URI, if I have match:
> > <map:match pattern="*/*.html">
>
> I see.
>
> >
> > I want to refer to the first wildcard inside the request: module,
> something
> > like:
> > <map:parameter name="param" value="{request:substring({1},0,1)}"
> > e.g. I want to apply XPath expression only on part of the URI using value
> > substitution.
>
> Quite natural desire. Unfortunately, this is not supported (I hope yet), but
> it would be very useful.
>
> > This is probably very stupid question, but I can't find an answer.
>
> Don't bother so much about stupid questions, if it were really stupid then
> I'd simply ignore it ;)
>
> > Can somebody please explain me this or redirect me to some URL with
> > explanations?
> > (I read the http://xml.apache.org/cocoon/userdocs/concepts/modules.html,
> but
> > it just explains the concept of modules, it doesn't have the example that
> I
> > need).
>
> Yes, that's true. The documentation for Input module is very short, but I
> hope that the sample (/samples/modules) demonstrates most of the
> possibilities.
>
> Konstantin
>
> >
> > Thank you very much for help.
> >
> > Anna
> >
> > ----- Original Message -----
> > From: "Konstantin Piroumian" <kp...@apache.org>
> > To: <co...@xml.apache.org>
> > Sent: Tuesday, December 17, 2002 2:13 PM
> > Subject: Re: value-substitution in Cocoon
> >
> >
> > Hi!
> > (Please do not use HTML mails in the mailing list.)
> >
> > I see two ways to solve this task:
> >   1. Use an action that will get the original parameter and generate
> another
> > one, which you'll pass to the transformer.
> >   2. Use a the Request input module, e.g.  <map:parameter name="param"
> > value="{request:substring(requestURI, 0, 1)}"/> - this sample will give
> you
> > the first letter (see /samples/module/sitemap.xmap and XPath reference to
> > learn how to get the last character).
> >
> > It sounds a little strange what you are trying to do though...
> >
> > Regards,
> >   Konstantin
> >
> > ----- Original Message -----
> > From: Anna Afonchenko
> > To: cocoon-users
> > Sent: Tuesday, December 17, 2002 14:55
> > Subject: value-substitution in Cocoon
> >
> >
> > I have the following question:
> > I know that in Cocoon I can use value substitution inside a pipeline, e.g.
> > if I have a pipeline
> > <map:pipeline>
> >   <map:match pattern="*/*.html">
> >     <map:generate src="{2}.html"/>
> >     <map:transform src="some.xsl">
> >       <map:parameter name="param" value="{1}"/>
> >     </map:transform>
> >   </map:match>
> > </map:pipeline>
> >
> > and if I write the URI http://localhost:8080/cocoon/param1/some.html
> >
> > then in the pipeline the stylesheet some.xsl will receive a parameter with
> > name param and value param1. So this is my question:
> > Can I somehow parse/evaluate this parameter {1} inside the sitemap (not
> > inside the xsl).
> > E.g., can I somehow, having {1}="param1" extract the last character ("1"
> in
> > this case) and send to the xsl only it, or, having parameter {1}=1, send
> > {1}+1, i.e. 2 to the stylesheet?
> >
> > I need this because I want to build pipeline that will get some parameter
> n,
> > and after it is executed I want to call the same pipeline with parameter
> > n+1.
> > Is this possible in sitemap?
> >
> > Thank you very much for help.
> >
> > Anna
> >
> >
> > ---------------------------------------------------------------------
> > 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>
>



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


Re: value-substitution in Cocoon

Posted by Konstantin Piroumian <kp...@apache.org>.
Hi Anna and Team!

CC-ing this message to Cocoon Dev list, cause it raises a more general
requirement for possibility to combine input modules with other input
modules in sitemap substitution values (see below for a use-case).

From: "Anna Afonchenko" <an...@ubaccess.com>
To: <co...@xml.apache.org>
Sent: Wednesday, December 18, 2002 12:23
Subject: Re: value-substitution in Cocoon


> Sorry for returning to this issue again, but I can't find an answer.
> Can I use value substitutoin inside the input module?
> Referring the example that yoou gave me, I don't want to get the substring
> of the whole URI, if I have match:
> <map:match pattern="*/*.html">

I see.

>
> I want to refer to the first wildcard inside the request: module,
something
> like:
> <map:parameter name="param" value="{request:substring({1},0,1)}"
> e.g. I want to apply XPath expression only on part of the URI using value
> substitution.

Quite natural desire. Unfortunately, this is not supported (I hope yet), but
it would be very useful.

> This is probably very stupid question, but I can't find an answer.

Don't bother so much about stupid questions, if it were really stupid then
I'd simply ignore it ;)

> Can somebody please explain me this or redirect me to some URL with
> explanations?
> (I read the http://xml.apache.org/cocoon/userdocs/concepts/modules.html,
but
> it just explains the concept of modules, it doesn't have the example that
I
> need).

Yes, that's true. The documentation for Input module is very short, but I
hope that the sample (/samples/modules) demonstrates most of the
possibilities.

Konstantin

>
> Thank you very much for help.
>
> Anna
>
> ----- Original Message -----
> From: "Konstantin Piroumian" <kp...@apache.org>
> To: <co...@xml.apache.org>
> Sent: Tuesday, December 17, 2002 2:13 PM
> Subject: Re: value-substitution in Cocoon
>
>
> Hi!
> (Please do not use HTML mails in the mailing list.)
>
> I see two ways to solve this task:
>   1. Use an action that will get the original parameter and generate
another
> one, which you'll pass to the transformer.
>   2. Use a the Request input module, e.g.  <map:parameter name="param"
> value="{request:substring(requestURI, 0, 1)}"/> - this sample will give
you
> the first letter (see /samples/module/sitemap.xmap and XPath reference to
> learn how to get the last character).
>
> It sounds a little strange what you are trying to do though...
>
> Regards,
>   Konstantin
>
> ----- Original Message -----
> From: Anna Afonchenko
> To: cocoon-users
> Sent: Tuesday, December 17, 2002 14:55
> Subject: value-substitution in Cocoon
>
>
> I have the following question:
> I know that in Cocoon I can use value substitution inside a pipeline, e.g.
> if I have a pipeline
> <map:pipeline>
>   <map:match pattern="*/*.html">
>     <map:generate src="{2}.html"/>
>     <map:transform src="some.xsl">
>       <map:parameter name="param" value="{1}"/>
>     </map:transform>
>   </map:match>
> </map:pipeline>
>
> and if I write the URI http://localhost:8080/cocoon/param1/some.html
>
> then in the pipeline the stylesheet some.xsl will receive a parameter with
> name param and value param1. So this is my question:
> Can I somehow parse/evaluate this parameter {1} inside the sitemap (not
> inside the xsl).
> E.g., can I somehow, having {1}="param1" extract the last character ("1"
in
> this case) and send to the xsl only it, or, having parameter {1}=1, send
> {1}+1, i.e. 2 to the stylesheet?
>
> I need this because I want to build pipeline that will get some parameter
n,
> and after it is executed I want to call the same pipeline with parameter
> n+1.
> Is this possible in sitemap?
>
> Thank you very much for help.
>
> Anna
>
>
> ---------------------------------------------------------------------
> 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>
>
>


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


Re: value-substitution in Cocoon

Posted by Konstantin Piroumian <kp...@apache.org>.
Hi Anna and Team!

CC-ing this message to Cocoon Dev list, cause it raises a more general
requirement for possibility to combine input modules with other input
modules in sitemap substitution values (see below for a use-case).

From: "Anna Afonchenko" <an...@ubaccess.com>
To: <co...@xml.apache.org>
Sent: Wednesday, December 18, 2002 12:23
Subject: Re: value-substitution in Cocoon


> Sorry for returning to this issue again, but I can't find an answer.
> Can I use value substitutoin inside the input module?
> Referring the example that yoou gave me, I don't want to get the substring
> of the whole URI, if I have match:
> <map:match pattern="*/*.html">

I see.

>
> I want to refer to the first wildcard inside the request: module,
something
> like:
> <map:parameter name="param" value="{request:substring({1},0,1)}"
> e.g. I want to apply XPath expression only on part of the URI using value
> substitution.

Quite natural desire. Unfortunately, this is not supported (I hope yet), but
it would be very useful.

> This is probably very stupid question, but I can't find an answer.

Don't bother so much about stupid questions, if it were really stupid then
I'd simply ignore it ;)

> Can somebody please explain me this or redirect me to some URL with
> explanations?
> (I read the http://xml.apache.org/cocoon/userdocs/concepts/modules.html,
but
> it just explains the concept of modules, it doesn't have the example that
I
> need).

Yes, that's true. The documentation for Input module is very short, but I
hope that the sample (/samples/modules) demonstrates most of the
possibilities.

Konstantin

>
> Thank you very much for help.
>
> Anna
>
> ----- Original Message -----
> From: "Konstantin Piroumian" <kp...@apache.org>
> To: <co...@xml.apache.org>
> Sent: Tuesday, December 17, 2002 2:13 PM
> Subject: Re: value-substitution in Cocoon
>
>
> Hi!
> (Please do not use HTML mails in the mailing list.)
>
> I see two ways to solve this task:
>   1. Use an action that will get the original parameter and generate
another
> one, which you'll pass to the transformer.
>   2. Use a the Request input module, e.g.  <map:parameter name="param"
> value="{request:substring(requestURI, 0, 1)}"/> - this sample will give
you
> the first letter (see /samples/module/sitemap.xmap and XPath reference to
> learn how to get the last character).
>
> It sounds a little strange what you are trying to do though...
>
> Regards,
>   Konstantin
>
> ----- Original Message -----
> From: Anna Afonchenko
> To: cocoon-users
> Sent: Tuesday, December 17, 2002 14:55
> Subject: value-substitution in Cocoon
>
>
> I have the following question:
> I know that in Cocoon I can use value substitution inside a pipeline, e.g.
> if I have a pipeline
> <map:pipeline>
>   <map:match pattern="*/*.html">
>     <map:generate src="{2}.html"/>
>     <map:transform src="some.xsl">
>       <map:parameter name="param" value="{1}"/>
>     </map:transform>
>   </map:match>
> </map:pipeline>
>
> and if I write the URI http://localhost:8080/cocoon/param1/some.html
>
> then in the pipeline the stylesheet some.xsl will receive a parameter with
> name param and value param1. So this is my question:
> Can I somehow parse/evaluate this parameter {1} inside the sitemap (not
> inside the xsl).
> E.g., can I somehow, having {1}="param1" extract the last character ("1"
in
> this case) and send to the xsl only it, or, having parameter {1}=1, send
> {1}+1, i.e. 2 to the stylesheet?
>
> I need this because I want to build pipeline that will get some parameter
n,
> and after it is executed I want to call the same pipeline with parameter
> n+1.
> Is this possible in sitemap?
>
> Thank you very much for help.
>
> Anna
>
>
> ---------------------------------------------------------------------
> 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: value-substitution in Cocoon

Posted by Anna Afonchenko <an...@ubaccess.com>.
Sorry for returning to this issue again, but I can't find an answer.
Can I use value substitutoin inside the input module?
Referring the example that yoou gave me, I don't want to get the substring
of the whole URI, if I have match:
<map:match pattern="*/*.html">

I want to refer to the first wildcard inside the request: module, something
like:
<map:parameter name="param" value="{request:substring({1},0,1)}"
e.g. I want to apply XPath expression only on part of the URI using value
substitution.
This is probably very stupid question, but I can't find an answer.
Can somebody please explain me this or redirect me to some URL with
explanations?
(I read the http://xml.apache.org/cocoon/userdocs/concepts/modules.html, but
it just explains the concept of modules, it doesn't have the example that I
need).

Thank you very much for help.

Anna

----- Original Message -----
From: "Konstantin Piroumian" <kp...@apache.org>
To: <co...@xml.apache.org>
Sent: Tuesday, December 17, 2002 2:13 PM
Subject: Re: value-substitution in Cocoon


Hi!
(Please do not use HTML mails in the mailing list.)

I see two ways to solve this task:
  1. Use an action that will get the original parameter and generate another
one, which you'll pass to the transformer.
  2. Use a the Request input module, e.g.  <map:parameter name="param"
value="{request:substring(requestURI, 0, 1)}"/> - this sample will give you
the first letter (see /samples/module/sitemap.xmap and XPath reference to
learn how to get the last character).

It sounds a little strange what you are trying to do though...

Regards,
  Konstantin

----- Original Message -----
From: Anna Afonchenko
To: cocoon-users
Sent: Tuesday, December 17, 2002 14:55
Subject: value-substitution in Cocoon


I have the following question:
I know that in Cocoon I can use value substitution inside a pipeline, e.g.
if I have a pipeline
<map:pipeline>
  <map:match pattern="*/*.html">
    <map:generate src="{2}.html"/>
    <map:transform src="some.xsl">
      <map:parameter name="param" value="{1}"/>
    </map:transform>
  </map:match>
</map:pipeline>

and if I write the URI http://localhost:8080/cocoon/param1/some.html

then in the pipeline the stylesheet some.xsl will receive a parameter with
name param and value param1. So this is my question:
Can I somehow parse/evaluate this parameter {1} inside the sitemap (not
inside the xsl).
E.g., can I somehow, having {1}="param1" extract the last character ("1" in
this case) and send to the xsl only it, or, having parameter {1}=1, send
{1}+1, i.e. 2 to the stylesheet?

I need this because I want to build pipeline that will get some parameter n,
and after it is executed I want to call the same pipeline with parameter
n+1.
Is this possible in sitemap?

Thank you very much for help.

Anna


---------------------------------------------------------------------
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: value-substitution in Cocoon

Posted by Konstantin Piroumian <kp...@apache.org>.
Hi!
(Please do not use HTML mails in the mailing list.)

I see two ways to solve this task:
  1. Use an action that will get the original parameter and generate another
one, which you'll pass to the transformer.
  2. Use a the Request input module, e.g.  <map:parameter name="param"
value="{request:substring(requestURI, 0, 1)}"/> - this sample will give you
the first letter (see /samples/module/sitemap.xmap and XPath reference to
learn how to get the last character).

It sounds a little strange what you are trying to do though...

Regards,
  Konstantin

----- Original Message -----
From: Anna Afonchenko
To: cocoon-users
Sent: Tuesday, December 17, 2002 14:55
Subject: value-substitution in Cocoon


I have the following question:
I know that in Cocoon I can use value substitution inside a pipeline, e.g.
if I have a pipeline
<map:pipeline>
  <map:match pattern="*/*.html">
    <map:generate src="{2}.html"/>
    <map:transform src="some.xsl">
      <map:parameter name="param" value="{1}"/>
    </map:transform>
  </map:match>
</map:pipeline>

and if I write the URI http://localhost:8080/cocoon/param1/some.html

then in the pipeline the stylesheet some.xsl will receive a parameter with
name param and value param1. So this is my question:
Can I somehow parse/evaluate this parameter {1} inside the sitemap (not
inside the xsl).
E.g., can I somehow, having {1}="param1" extract the last character ("1" in
this case) and send to the xsl only it, or, having parameter {1}=1, send
{1}+1, i.e. 2 to the stylesheet?

I need this because I want to build pipeline that will get some parameter n,
and after it is executed I want to call the same pipeline with parameter
n+1.
Is this possible in sitemap?

Thank you very much for help.

Anna


---------------------------------------------------------------------
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>