[MarkLogic Dev General] Escaping text?

Andrew Welch andrew.j.welch at gmail.com
Wed Mar 3 10:55:09 PST 2010


On 3 March 2010 18:31, Wyatt VanderStucken <marklogic at wylovan.com> wrote:
> I've been banging my head trying to figure this out - any ideas would be
> much appreciated....
>
> let $ex as xs:string := '<exception message="One of
> ''{&quot;http://www.w3.org/1998/Math/MathML&quot;:semantics}'' is
> expected."/>'
> return xdmp:unquote($ex)
>
> Always gives error "SystemID: XDMP-DOCSTARTTAGCHAR: xdmp:unquote("<exception
> message=&quot;One of '{&quot;http://www.w3.org/1998/M...") -- Unexpected
> character "/" in start tag at  line 1"

That's because &quot; gets resolved to " when the query is parsed, so
your variable $ex becomes:

<exception message="One of '{"http....

..you can see the double quotes that are causing the exception when
you try and parse that as XML using xdmp:unquote.

One answer is to double escape them:

message="One of ''{&amp;quot;

..then after the query is parsed you are left with "&quot;" as expected.

cheers
andrew


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/


More information about the General mailing list