Sequence does not match type xs:string error Xquery



I am using BDB XML 2.5.16 to store and query my XML documents in Java. The documents are IMDB xml documents containing actors information obtained from INEX website http://ift.tt/15jg33e. One of the document I stored in the database is the following



<?xml version="1.0" encoding="UTF-8"?>
<persons>
<person>
<name>jason angeles
</name>
<filmography>
<act>
<movie>
<title>prison planet 3 the revenge 1998
</title>
<year>1998
</year>
<character>evil ninja
</character>
</movie>
</act>
</filmography>
</person>
</persons>


I want to search (using XQuery ) for filmography element whose title element contains ANY of the following keywords ('planet', 'revenge', '1998') and /act/movie/year or direct/movie/year equals to 1998. Below is the query I used



// declaring function functx:contains-any-of

String qryRk = "declare namespace functx = 'http://www.functx.com'; "
+ "declare function functx:contains-any-of "
+ "( $arg as xs:string?" + " , " + " $searchStrings as xs:string* )
as xs:boolean { " + "some $searchString in $searchStrings "
+ " satisfies contains($arg,$searchString)} ; ";

String myQuery101 = qryRk + "for $entity in
collection('simpleExampleData2.dbxml')//filmography "
+ "where functx:contains-any-of ( $entity/act/movie/title ,
('planet', 'revenge', '1998'))"
+ "and ( contains ( $entity/act/movie/year , '1998' ) "
+ "or contains ( $entity/direct/movie/year , '1998' ))"
+ "return $entity";


When I executed the query, I expect to get at least the following element as my output



Document : person_31000.xml:
<filmography>
<act>
<movie>
<title>prison planet 3 the revenge 1998
</title>
<year>1998
</year>
<character>evil ninja
</character>
</movie>
</act>
</filmography>


However instead of the above element I got the following Error



Exception in thread "main" com.sleepycat.dbxml.XmlException: Error:
Sequence does not match type xs:string? - the sequence contains more
than one item [err:XPTY0004], <query>:1:343, errcode =
QUERY_EVALUATION_ERROR at
com.sleepycat.dbxml.dbxml_javaJNI.XmlManager_query__SWIG_0(Native
Method) at
com.sleepycat.dbxml.XmlManager.query(XmlManager.java:544)
at

com.sleepycat.dbxml.XmlManager.query(XmlManager.java:320)
at

xmlirsystemstruxplus.XQueryEngine.queryEngine(XQueryEngine.java:269)
at

xmlirsystemstruxplus.XMLIRSystemStruXplus.main(XMLIRSystemStruXplus.java:109)
Java Result: 1


Note that i used contains-any-of() function because the contains () function does not work with 'planet revenge 1998' string may be because the keywords do not appear in the order they appear in the element content.


Please can any body help me to find out (1) why i have the above error ? and solution (2) why the condition contains ( $entity/act/movie/title , 'planet revenge 1998') is not working ? how do i use contains() function w.r.t this


Thank you in advance


No comments:

Post a Comment