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