If you DON'T do a request-parameter() in the xquery, then the parameter come
via Cocoon:

test.xq:
xquery version "1.0";

declare namespace request="http://exist-db.org/xquery/request";;
declare variable $var2 external;
let $var1 := request:request-parameter("var1", "var1 not set")
return
<html>
    <h1>TEST</h1>
    <h2>var1 = {$var1}</h2>
    <h2>var2 = {$var2}</h2>
</html>

sitemap:
                        <map:match pattern="example.xq">
                                <map:generate src="/test.xq" type="xquery">
                                        <map:parameter name="var2"
value="set by cocoon"/>
                                </map:generate>
                                <map:serialize encoding="UTF-8"
type="html"/>
                        </map:match>

URL:
http://localhost:8080/exist/xquery/example.xq?var1=1

Output:
TEST
var1 = 1
var2 = set by cocoon 


*** NOW, how do you modify it, so if the URL passes var2 it use it in the
xquery.  If not set on the URL, then var2 is set by Cocoon?



mountainbiker wrote:
> 
> If I do not want the parameter set from (1) the calling URL or (2) by
> default in the xquery (.xq) -- can you explain how request-param is
> picking up the parameter for "format" and setting it to "summary"?
> 
> Maybe you can show me the sitemap snippet, and the calling URL.
> 
> 
> 
> André Davignon wrote:
>> 
>> You _don't_ need to match anything else, match "article" and pick the 
>> parameter's value with request-param.
>> 
>> André
>> 
>>> Wouldn't request-param simply attempt to grab the value from the URL and
>>> still require me to make the URL call like
>>> http://myhost/cocoon/article?format=summary&docid=12345?
>>>
>>>
>>>
>>> André Davignon wrote:
>>>   
>>>> Hi,
>>>>
>>>> I guess you should use the "request-param" input module :
>>>>
>>>> <map:generate src="xquery/exist-article.xq" type="xquery">
>>>>    <map:parameter name="format" value="{request-param:format}"/> 
>>>> </map:generate>
>>>>
>>>> Cheers,
>>>>
>>>> André
>>>>
>>>>
>>>>     
>>>>> I have a sitemap entry that reads
>>>>>
>>>>> <map:match pattern="article">
>>>>>          <map:generate src="xquery/exist-article.xq" type="xquery"/>
>>>>>          <map:transform type="xinclude"/>
>>>>>          <map:transform src="stylesheets/db2html.xsl"/>
>>>>>          <map:serialize type="html"/>
>>>>> </map:match>
>>>>>
>>>>> and I call it like
>>>>> http://myhost/cocoon/article?format=summary&docid=12345.
>>>>>
>>>>> I tried to do another sitemap entry like
>>>>>
>>>>> <map:match pattern="summary">
>>>>>          <map:generate src="xquery/exist-article.xq" type="xquery">
>>>>>                   <map:parameter name="format" value="summary"/> 
>>>>>          </map:generate>
>>>>>          <map:transform type="xinclude"/>
>>>>>          <map:transform src="stylesheets/db2html.xsl"/>
>>>>>          <map:serialize type="html"/>
>>>>> </map:match>
>>>>>
>>>>> and I call it like http://myhost/cocoon/article?docid=12345.  HOWEVER,
>>>>> the
>>>>> variable summary does not  get set.
>>>>>
>>>>> I have passed parameter like this to XSLTs without issue.  However,
>>>>> can I
>>>>> pass a parameter like this to the xquery?  
>>>>>
>>>>>   
>>>>>       
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>>
>>>>     
>>>
>>>   
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Cocoon-sitemap-pattern-match-parameter-passing-tp23459093p23465626.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to