I think that the problem is that within your <options> element, you're using a 
default namespace ("http://marklogic.com/appservices/search";), which is the 
namespace that's in scope within that expression.

Probably the easiest solution is put the <facets> element in that same 
namespace (currently it's in the "empty" namespace):

let $node :=
<facets xmlns="http://marklogic.com/appservices/search";>
<facet-element>
<facet-name datatype="xs:string">title</facet-name>
<element ns="http://marklogic.com/ls"; name="title"/> </facet-element> </facets>
let $options :=
<options xmlns="http://marklogic.com/appservices/search";>
{
for $i in $node/facet-element
return  <constraint name="{$i/facet-name}" facet="true" > <range 
collation="http://marklogic.com/collation/";
type="{$i/facet-name/@datatype}">
<facet-option>limit=10</facet-option>
{$i/element}
</range>
</constraint>
}                                               
<return-results>true</return-results>
<return-facets>true</return-facets>
</options>
return $options


Or you could explicitly declare the search namespace you are using, and 
explicitly use that namespace rather than using a default namespace:

declare namespace search="http://marklogic.com/appservices/search";;
let $node :=
<facets>
<facet-element>
<facet-name datatype="xs:string">title</facet-name>
<element ns="http://marklogic.com/ls"; name="title"/> </facet-element> </facets>
let $options :=
<search:options >
{
for $i in $node/facet-element
return  
<search:constraint name="{$i/facet-name}" facet="true" > 
  <search:range collation="http://marklogic.com/collation/";
    type="{$i/facet-name/@datatype}">
  <search:facet-option>limit=10</search:facet-option>
  {$i/element}
  </search:range>
</search:constraint>
}                                               
<search:return-results>true</search:return-results>
<search:return-facets>true</search:return-facets>
</search:options>
return $options




-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Pradeep Maddireddy
Sent: Monday, April 26, 2010 11:59 AM
To: General
Subject: [MarkLogic Dev General] Query Help

Hi..!

Can some one tell me why this query is failing
------------------------------------------------------------------------------------------------------
let $node :=
<facets>
<facet-element>
<facet-name datatype="xs:string">title</facet-name>
<element ns="http://marklogic.com/ls"; name="title"/>
</facet-element>
</facets>
let $options          :=
<options xmlns="http://marklogic.com/appservices/search";>
{
for $i in $node/facet-element
return  <constraint name="{$i/facet-name}" facet="true" >
<range collation="http://marklogic.com/collation/";
type="{$i/facet-name/@datatype}">
<facet-option>limit=10</facet-option>
{$i/element}
</range>
</constraint>
}                                               
<return-results>true</return-results>
<return-facets>true</return-facets>
</options>
return      $options
------------------------------------------------------------------------------------------------------
When  I remove the namespace declaration
"xmlns="http://marklogic.com/appservices/search"";  from the options
node I get the desired result, but when I have the namespace the query
fails.

Thanks
Pradeep Maddireddy
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to