Solutions

MarkLogic Data Hub Service

Fast data integration + improved data governance and security, with no infrastructure to buy or manage.

Learn More

Learn

Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

Community

Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

Company

Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

 
Knowledgebase:
XQuery ampersand in string
26 May 2015 02:32 PM

Summary

The ampersand is a special character used to denote a predefined entity reference in a string literal.

XQuery W3C Recommendation

Can be found at http://www.w3.org/TR/xquery-30/ .

Section 2.4.5 'URI Literals'  states "Certain characters, notably the ampersand, can only be represented using a 'predefined entity reference' or a 'character reference'."

Section 3.1.1 'Literals' defines the predefined entity reference for ampersand as "&".

Issues with the ampersand character

The ampersand character can be tricky to construct in an XQuery string, as it is an escape character to the XQuery parser. The ways to construct the ampersand character in XQuery are:

  • Use the XML entity syntax (for example, &).
  • Use a CDATA element (<![CDATA[element content here]]>), which tells the XQuery parser to read the content as character data.
  • Use the repair option on xdmp:document-loadxdmp:document-get, or xdmp:unquote.

For additional details and examples, please refer to XML Data Model Versus Serialized XML in the MarkLogic Server's XQuery and XSLT Reference Guide.

(3 vote(s))
Helpful
Not helpful

Comments (0)