Silly XQUERY exception
Wednesday, 7 January 2015 · 3 messages · last reply 8 Jan 2015
MS
Mansi Sheth7 Jan 2015 20:13 #
Hello,
I feel very stupid and frustrated, not able to fix this error:
Below, is a my query code, which I am trying to run. I am passing the value for "contains" clause thru command line and I expect to receive # of xml files matching $cmd xpath. I always get
Stopped at /veracode/msheth/BaseXWeb/get_prevalence.xq, 16/12: *[XPST0003] Expecting ':=', found ':'.*
When ran thru REST:
*[XPST0003] Expecting valid step, found 'd'.*
I think, its the way $cmd is being set. I have tried, simple string concat using ||, using concat command, using html entities etc.
declare variable $n as xs:string external;
declare option output:item-separator "
";
(: let $cmd :=
concat("/A/*/descendant::C/descandant::*[contains(@name,",$singlequote,$n,$singlequote,")]")
:)
*let $cmd := "/A/*/descendant::C/descandant::*[contains(@name,'"|| $n
||"')]"*
let $aPath :=
for $db in db:list()
let $query :=
"declare variable $db external; " ||
"db:open($db)" || $cmd
*return xquery:eval($query,*
* map { 'db': $db, 'query': $cmd })*
let $clients :=
for $elem in $aPath
return db:path($elem)return $n , distinct-values(count($clients))
Lines of code, which are the culprit, are marked in bold above. Any and all suggestions are greatly appreciated.
- Mansi
LK
Lukas Kircher8 Jan 2015 08:44 #
Hi Mansi,
Quoted text · Mansi Sheth · 1 line
> let $cmd := "/A/*/descendant::C/descandant::*[contains(@name,'"|| $n ||"')]”
Just a quick scan - I marked the problem in <bold> above - I would try ‘descendant’ instead of 'descandant’.
Cheers,
Lukas
MS
Mansi Sheth8 Jan 2015 16:53 #
Lukas,
That was it!! I feel like shooting myself. What an oversight.
Thanks a ton for looking at it and spotting it.
- Mansi
Quoted text · Lukas Kircher · 16 lines
On Thu, Jan 8, 2015 at 2:44 AM, Lukas Kircher <lukaskircher1 at gmail.com> wrote: > Hi Mansi, > > let $cmd := "/A/*/descendant::C/*descandant*::*[contains(@name,'"|| $n > ||"')]” > > > Just a quick scan - I marked the problem in <bold> above - I would try > ‘desc*e*ndant’ > instead of 'desc*a*ndant’. > > Cheers, > Lukas > >
--
- Mansi
Written for BaseX 7.9. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery