Hello,

I'm trying to create a query with several parameters, including one 
which is a count of elements and another that needs to only search on 
the first element value.

I am currently checking for these outside of the query itself, but it 
would be nice (and more optimised?) to have everything inside the query 
itself. (Or perhaps this is a wrong assumption?)

Any thoughts as to how this could be done? Or am I barking up the wrong 
tree?

So far, I have the following:

xquery version "1.0-ml";
declare namespace meta="http://semantico.com/meta";;

declare variable $eissn := '1476-4687';
declare variable $issn := '1422-468X';
declare variable $volume := '460';
declare variable $authorLastName := fn:lower-case('Tung');
declare variable $noOfAuthors := 6;


declare function local:finder() as node()* {

let $eissnstrip := fn:replace($eissn, '-', '')
let $issnstrip := fn:replace($issn, '-', '')
for $meta in cts:search(/record/metadata,
   cts:and-query((

     cts:or-query((
       cts:element-value-query(
         xs:QName("meta:eissn"),
         $eissn, ("punctuation-insensitive", "case-insensitive")),
       cts:element-value-query(
         xs:QName("meta:eissn"),
         $eissnstrip, ("punctuation-insensitive", "case-insensitive")),
       cts:element-value-query(
         xs:QName("meta:issn"),
         $issn, ("punctuation-insensitive", "case-insensitive")),
       cts:element-value-query(
         xs:QName("meta:issn"),
         $issnstrip, ("punctuation-insensitive", "case-insensitive"))
     )),

     cts:element-value-query(
       xs:QName("meta:volume"),
       $volume)
  ))
)
where fn:lower-case($meta/meta:authors/meta:author[1]/meta:last) = 
$authorLastName
and count($meta/meta:authors/meta:author) = $noOfAuthors
return
  $meta
};




_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to