You might give this a try:
xquery version "1.0";
(: $Id: get-children-rubriques.xq 12373 2008-10-15 14:41:34Z pdechandol $ :)
(: XQuery qui retourne la collection de notices Bmgexporub liée à une
notice parent :)
let $rubriques :=
fn:collection('Bmgexporub')/record[lien_rubrique_parent='Bmgexporub-0000002']
return
<records>
{
for $rubrique in $rubriques
return $rubrique
}
</records>
Robby
From: Patricia Déchandol [mailto:[email protected]]
Sent: Wednesday, March 21, 2012 12:22 PM
To: [email protected]
Subject: Problem with query in Cocoon
Hi everybody,
new problem !
I try to execute query from cocoon
I declared a xquery generator in my sitemap :
<map:generator name="xquery" logger="sitemap.generator.xquery"
src="org.exist.cocoon.XQueryGenerator"
collection="xmldb:exist://localhost:8899/exist/xmlrpc/db"
user="admin"
password="admin"
create-session="false"
expand-xincludes="false"
authen=""
cache-validity="-1"
/>
I match a pattern corresponding :
<map:match pattern="**/get-children-rubriques.xml">
<map:generate type="xquery" src="xq/get-children-rubriques.xq">
<map:parameter name="parentid" value="{request-param:parentid}"/>
</map:generate>
<map:serialize type="xml"/>
</map:match>
I prepared the following .xq:
xquery version "1.0";
(: $Id: get-children-rubriques.xq 12373 2008-10-15 14:41:34Z pdechandol $ :)
(: XQuery qui retourne la collection de notices Bmgexporub liée à une
notice parent :)
let $rubriques :=
fn:collection('Bmgexporub')/record[lien_rubrique_parent='Bmgexporub-0000002']
<records>
return $rubriques
</records>
Executing the following URL :
http://localhost:8080/bm-grenoble/Bmgexporub/get-children-rubriques.xml?parentid=Bmgexporub-0000002
the response is this one :
Erreur d'analyse XML : aucun élément trouvé
Emplacement :
http://localhost:8080/bm-grenoble/Bmgexporub/get-children-rubriques.xml?parentid=Bmgexporub-0000002
Numéro de ligne 1, Colonne 1 :
with the following logs :
<parsererror>
Erreur·d'analyse·XML :·aucun·élément·trouvé¶Emplacement :·http://localhost:8080/bm-grenoble/Bmgexporub/get-children-rubriques.xml?parentid=Bmgexporub-0000002¶Numéro·de·ligne·1,·Colonne·1 :
<sourcetext>¶^</sourcetext>
</parsererror>
I checked that my query request is correct by testing in the eXist client.
I can't understand at which level there's an error… lo log in tomcat !!!
Patricia