Search code examples
xquerymarklogic

XQuery Invalid entity reference error caused by “ ” entity reference


I am trying to insert following code in QConsole but keep getting the below mentioned error.

[1.0-ml] XDMP-ENTITYREF: (err:XPST0003) Invalid entity reference " "
Stack Trace
At line 4 column 6:
In xdmp:eval("xquery version &quot;1.0-ml&quot;;&#10;let $uri := &quot;/mlrepo...", (), <options xmlns="xdmp:eval"><database>1979476059788016196</database>...</options>)

2. let $uri := "/mlreports/corb/arena_report.txt"
3. let $code :=
4. <code>
5. THREAD-COUNT=10
6. BATCH-SIZE=10

Below is the query, I am executing -

xquery version "1.0-ml";
let $uri := "/mlreports/corb/arena_report.txt"
let $code :=
<code>
THREAD-COUNT=10
BATCH-SIZE=10
URIS-MODULE=/mlreports/selector/arena_report_selector.xqy
PROCESS-MODULE=/mlreports/transform/arena_report_transform.xqy
PROCESS-TASK=com.marklogic.developer.corb.ExportBatchToFileTask
EXPORT-FILE-NAME=arena_report.csv
PRE-BATCH-TASK=com.marklogic.developer.corb.PreBatchUpdateFileTask
EXPORT-FILE-TOP-CONTENT=UNIFIED DOC ID,SEAL ID,DMS NAME,DOCUMENT ID,PRODUCT ID,Legal Entity ID,Client ID,Client Type,Party Role,Document Type ID,Document Type Name,Document Title ID,Document Title,Document Source,Creation Date,Published Date,Effective Date,Document Electronic Storage Location,Document Status,Document Classification,Document Expiration Date,Document Modification Date,Country Of Governing Law,State Of Governing Law,Collection ID,Collection Name,Image ID,Image Type,Image Format,Image Effective Date,Image Source,Image Tag Classification,Resolution & Recovery LOB,Resolution & Recovery Sub-LOB,Facility ID,Agreement Version,LIBOR_METADATA_0,LIBOR_METADATA_1,LIBOR_METADATA_2,LIBOR_METADATA_3,LIBOR_METADATA_4,LIBOR_METADATA_5,LIBOR_METADATA_6,LIBOR_MANUAL_REVIEW_0,LIBOR_MANUAL_REVIEW_1,LIBOR_MANUAL_REVIEW_2,LIBOR_MANUAL_REVIEW_3,LIBOR_MANUAL_REVIEW_5,LIBOR_MANUAL_REVIEW_6,LIBOR_MANUAL_REVIEW_7,LIBOR_MANUAL_REVIEW_8,LIBOR_MANUAL_REVIEW_10,LIBOR_MANUAL_REVIEW_11,LIBOR_MANUAL_REVIEW_15,LIBOR_MANUAL_REVIEW_19,LIBOR_MANUAL_REVIEW_23,LIBOR_MANUAL_REVIEW_27,LIBOR_MANUAL_REVIEW_31,LIBOR_MANUAL_REVIEW_35,LIBOR_MANUAL_REVIEW_39,LIBOR_MANUAL_REVIEW_43,LIBOR_MANUAL_REVIEW_47,LIBOR_MANUAL_REVIEW_51,LIBOR_MANUAL_REVIEW_55,LIBOR_MANUAL_REVIEW_59,LIBOR_MANUAL_REVIEW_63,LIBOR_MANUAL_REVIEW_67,LIBOR_MANUAL_REVIEW_71,L,BOR_MANUAL_REVIEW_75,LIBOR_MANUAL_REVIEW_79,LIBOR_MANUAL_REVIEW_83,LIBOR_MANUAL_REVIEW_87,IBOR_MANUAL_REVIEW_91,LIBOR_MANUAL_REVIEW_95,LIBOR_MANUAL_REVIEW_99,LIBOR_MANUAL_REVIEW_103,LIBOR_INSCOPE_0,LIBOR_CLUSTER_0,LIBOR_CLUSTER_1,LIBOR_CLUSTER_2,LIBOR_CLUSTER_3,LIBOR_CLUSTER_4,LIBOR_CLUSTER_5
</code>/text()

return xdmp:document-insert($uri, $code,(xdmp:permission("clientDocsReadRole", "read"),
  xdmp:permission("clientDocsWriteRole", "insert"),
  xdmp:permission("clientDocsWriteRole", "update")))

I am unable to understand the reason behind the error. Any help is much appreciated.


Solution

  • It seems that the content in the EXPORT-FILE-TOP-CONTENT is the problem, specifically the "&" sign. Example: "Resolution & Recovery LOB".

    "&" is interpreted as entity so:

    1. either wrap contents of <code> in CDATA or
    2. escape the & to &amp; or
    3. replace the occurrences of "&" with something else, like "and"