[Fwd: Re: org.exist.cocoon.XQueryGenerator - Is there a Bug]

View: New views
4 Messages — Rating Filter:   Alert me  

[Fwd: Re: org.exist.cocoon.XQueryGenerator - Is there a Bug]

by Peter Sparkes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Kai,

I spent a whole day trying figure out what the problem was without
realising that sitemap parameters did not have to be declared in the
xquery .xq. Now working

Thanks again

Peter

> Peter Sparkes <> wrote:
>  
>> Hi
>>
>> eXist Javadocs for org.exist.cocoon.XQueryGenerator states:
>>
>> "A generator for Cocoon which reads an XQuery script, executes it and
>> passes the results into the Cocoon pipeline. The following optional
>> attributes are accepted on the component declaration as default eXist
>> settings:
>> collection: identifies the XML:DB root collection used to process the
>> request
>> user
>> password
>> authen: if set to session, then use the user and password from the
>> session. Otherwise use the parameter values.
>> create-session: if set to "true", indicates that an HTTP session
>> should be created upon the first invocation.
>> expand-xincludes
>> cache-validity: if specified, the XQuery content is cached until the
>> specified delay expressed in milliseconds is elapsed or until the
>> XQuery file is modified. The identity of the cached content is
>> computed using the XQuery file URI and the list of all parameters
>> passed to the XQuery.
>> The component also accept default parameters that will be declared as
>>   implicit variables in the XQuery. See below an example declaration
>>   of the XQueryGenerator component with default eXist settings, and
>>   an extra user-defined parameter: These settings and parameters can
>>   be overriden on a per-pipeline basis with sitemap parameters, see
>>   below with default values and the extra user-defined parameter:
>>   <map:parameter name="collection" value="xmldb:exist:///db"/>
>>   <map:parameter name="user" value="guest"/> <map:parameter
>> name="password" value="guest"/> <map:parameter name="create-session"
>> value="false"/> <map:parameter name="expand-xincludes"
>> value="false"/> <map:parameter name="cache-validity" value="-1";/>
>> <map:parameter name="myProjectURI" value="/db/myproject"/>
>>
>> The last sitemap parameter overrides the value of the XQuery variable
>> defined in the component parameters, whereas others override the
>> default eXist settings defined on the component attributes."
>>
>> However, with the  following sitemap component and xquiry
>>
>> <map:match pattern="test.xq">
>>       <map:generate src="test.xq" type="xquery">
>>             <map:parameter name="myuser" value="peter"/>
>>        </map:generate>
>>        <map:serialize type="xml"/>
>>  </map:match>
>>
>> xquery version "1.0";
>> declare namespace xdb="http://exist-db.org/xquery/xmldb";
>> declare namespace request="http://exist-db.org/xquery/request";
>> let $myuser := request:get-parameter("myuser", 'error' )
>>  return
>>     <p>myuser - {$myuser}</p>
>>
>> Results in <p>myuser - error</p> not as it should <p>myuser -
>> peter</p>
>>
>> Is this a bug
>>    
>
> No. You are refering to a sitemap parameter not a request parameter.
> XQueryGenerator passes the parameters from sitemap to the XQuery. Thus you
> can use $myuser without declaring it.
>  




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: org.exist.cocoon.XQueryGenerator - Is there a Bug]

by thomas.0007 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Peter and Kai,

I have tried this approach but  I recieve the following Cocoon error:

XPDY0002 : variable '$p2' is not set. [at line 49, column 34]
org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
org.apache.cocoon.ProcessingException: XMLDBException occurred: XPDY0002 :
variable '$p2' is not set. [at line 49, column 34]:
org.xmldb.api.base.XMLDBException: XPDY0002 : variable '$p2' is not set. [at
line 49, column 34]
cause: org.exist.xquery.XPathException: XPDY0002 : variable '$p2' is not
set. [at line 49, column 34]

The sitemap fragment is:
<map:match pattern="run/*/*">
    <map:generate src="running-context.xq" type="xquery">
        <map:parameter name="p1" value="{%1}"/>
        <map:parameter name="p2" value="{%2}"/>
    </map:generate>
    <map:serialize encoding="UTF-8" type="xml"/>
</map:match>

and running-context.xq:
xquery version "1.0";
declare option exist:serialize "method=xml media-type=text/xml";
<running-context>
    <parameter cocoon_name="p2">{$p2}</parameter>
</running-context>


Am I missing something?

Regards,
Thomas


"Peter Sparkes" <peter@...> wrote in message
news:489F7D28.6040104@......

> Thanks Kai,
>
> I spent a whole day trying figure out what the problem was without
> realising that sitemap parameters did not have to be declared in the
> xquery .xq. Now working
>
> Thanks again
>
> Peter
>
>> Peter Sparkes <> wrote:
>>
>>> Hi
>>>
>>> eXist Javadocs for org.exist.cocoon.XQueryGenerator states:
>>>
>>> "A generator for Cocoon which reads an XQuery script, executes it and
>>> passes the results into the Cocoon pipeline. The following optional
>>> attributes are accepted on the component declaration as default eXist
>>> settings:
>>> collection: identifies the XML:DB root collection used to process the
>>> request
>>> user
>>> password
>>> authen: if set to session, then use the user and password from the
>>> session. Otherwise use the parameter values.
>>> create-session: if set to "true", indicates that an HTTP session
>>> should be created upon the first invocation.
>>> expand-xincludes
>>> cache-validity: if specified, the XQuery content is cached until the
>>> specified delay expressed in milliseconds is elapsed or until the
>>> XQuery file is modified. The identity of the cached content is
>>> computed using the XQuery file URI and the list of all parameters
>>> passed to the XQuery.
>>> The component also accept default parameters that will be declared as
>>>   implicit variables in the XQuery. See below an example declaration
>>>   of the XQueryGenerator component with default eXist settings, and
>>>   an extra user-defined parameter: These settings and parameters can
>>>   be overriden on a per-pipeline basis with sitemap parameters, see
>>>   below with default values and the extra user-defined parameter:
>>>   <map:parameter name="collection" value="xmldb:exist:///db"/>
>>>   <map:parameter name="user" value="guest"/> <map:parameter
>>> name="password" value="guest"/> <map:parameter name="create-session"
>>> value="false"/> <map:parameter name="expand-xincludes"
>>> value="false"/> <map:parameter name="cache-validity" value="-1";/>
>>> <map:parameter name="myProjectURI" value="/db/myproject"/>
>>>
>>> The last sitemap parameter overrides the value of the XQuery variable
>>> defined in the component parameters, whereas others override the
>>> default eXist settings defined on the component attributes."
>>>
>>> However, with the  following sitemap component and xquiry
>>>
>>> <map:match pattern="test.xq">
>>>       <map:generate src="test.xq" type="xquery">
>>>             <map:parameter name="myuser" value="peter"/>
>>>        </map:generate>
>>>        <map:serialize type="xml"/>
>>>  </map:match>
>>>
>>> xquery version "1.0";
>>> declare namespace xdb="http://exist-db.org/xquery/xmldb";
>>> declare namespace request="http://exist-db.org/xquery/request";
>>> let $myuser := request:get-parameter("myuser", 'error' )
>>>  return
>>>     <p>myuser - {$myuser}</p>
>>>
>>> Results in <p>myuser - error</p> not as it should <p>myuser -
>>> peter</p>
>>>
>>> Is this a bug
>>>
>>
>> No. You are refering to a sitemap parameter not a request parameter.
>> XQueryGenerator passes the parameters from sitemap to the XQuery. Thus
>> you
>> can use $myuser without declaring it.
>>
>
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/ 




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: org.exist.cocoon.XQueryGenerator - Is there a Bug]

by Martin Holz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Thomas White" <thomas.0007@...> writes:

> Dear Peter and Kai,
>
> I have tried this approach but  I recieve the following Cocoon error:
>
> XPDY0002 : variable '$p2' is not set. [at line 49, column 34]
>
> The sitemap fragment is:
> <map:match pattern="run/*/*">
>     <map:generate src="running-context.xq" type="xquery">
>         <map:parameter name="p1" value="{%1}"/>                                          
>         <map:parameter name="p2" value="{%2}"/>
>     </map:generate>
>     <map:serialize encoding="UTF-8" type="xml"/>
> </map:match>

Shouldn't this be
<map:parameter name="p1" value="{1}" />
without "%" ?


Martin


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: org.exist.cocoon.XQueryGenerator - Is there a Bug

by thomas.0007 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Martin,

Yes, it should be without the percentage sign. Thanks.

I found the reason for the error message and I think it could be of value
for others who use Cocoon sitemaps.

In my sitemap file I have two refference to running-context.xq:

<map:match pattern="run/*/*">
    <map:generate src="running-context.xq" type="xquery">
        <map:parameter name="p1" value="{%1}"/>
        <map:parameter name="p2" value="{%2}"/>
    </map:generate>
    <map:serialize encoding="UTF-8" type="xml"/>
</map:match>

<map:match pattern="running-context">
    <map:generate src="running-context.xq" type="xquery">
        <map:parameter name="p1" value="p-1-test-value"/>
      </map:generate>
    <map:serialize encoding="UTF-8" type="xml"/>
</map:match>

The second pattern does not pass p2 parameter and that is why the papeline
gives an error message.

I hope this will help.

Regards,
Thomas




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open
LightInTheBox - Buy quality products at wholesale price!