Search code examples
xquerymarklogic

Marklogic, Xquery


I am working on the MarkLogic Query Console. My XQuery file is not working properly and I am facing this error MarkLogic Xquery request error:

XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Dollar_"

This is the code that I am executing:

declare function fill:getA() as node()* { 
  for $projectId in /cf:Project/@Id/string() 
    $s := fill:getS($projectId)    
    $t := fill:getT($projectId) 

Solution

  • OK. After you provided the code in the comments, I pasted it into the ticket for you. Before even trying to format it, it is clear that the code is in error.. Variable assignment in xQuery starts with let as in:

    let $foo := bar
    

    not

    $foo := bar
    

    Therefore, you errors start here:

     for $projectId in /cf:Project/@Id/string() $sourceCatalogId := fill
     ...
    

    That should at leas read:

    for $projectId in /cf:Project/@Id/string()
      let $sourceCatalogId := fill
      ...
    

    Please note the let before the dollar sign. This is also what the error is saying to you - "I am not expecting a dollar sign.. - likely because it expects the word let.

    I did not check over the rest of the code. This should be enough to point you in the direction of cleaning the code. Also, using an Query-aware editor will help you here as well.