Niel
Niel

Reputation: 31

learning about the MarkLogic CoRB processing part 2

Im trying to export the data within my MarkLogic database into CSV format using CoRB. and the Process Query has been giving out XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_, expecting Exteral_ or ColonEquals_ or Lbrace_

My XML data (customer1~10.xml)

<?xml version="1.0" encoding="UTF-8"?>
<customer>
  <name>Customer1</name>
  <address>123 Main St</address>
  <company>A Corporation</company>
  <emailAddress>[email protected]</emailAddress>
</customer>

My Uri query

xquery version "1.0-ml";
let $dir := "/"
let $listDoc := cts:uris((), (), cts:directory-query($dir, "infinity"))

let $count := fn:count($listDoc)
let $URI := ($count, $listDoc)
return $listDoc

My Process query

xquery version "1.0-ml";

declare variable $URI xs:string external;
let $elementNames := ("name", "address", "company", "emailAddress")
let $doc := cts:search(/*, cts:document-query($URI))
let $textOutput := 
  for $i in $elementNames
    return $doc/*[fn:name() = $i]/text()
return fn:string-join($textOutput, ",")

Upvotes: 1

Views: 70

Answers (1)

Mads Hansen
Mads Hansen

Reputation: 66781

You are missing as when asserting the type of the $URI variable:

declare variable $URI as xs:string external;

You can test and troubleshoot your modules in Query Console. For syntax errors such as this, if you tried to execute it would give you an error message and point to where the problem is:

[1.0-ml] XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_, expecting External_ or ColonEquals_ or Lbrace_ Stack Trace At line 3 column 22: In xdmp:eval("xquery version &quot;1.0-ml&quot;;&#10;&#10;declare variable $UR...", (), <options xmlns="xdmp:eval"><database>10042031709667560285</database>...</options>)

  1. xquery version "1.0-ml";
  2. declare variable $URI xs:string external;

Also, if you wanted to test your process module, you can assign a single value to the $URI to process:

declare variable $URI as xs:string external := "/testDoc.xml";

Upvotes: 1

Related Questions