[MarkLogic Dev General] Escaping text?
Wyatt VanderStucken
marklogic at wylovan.com
Wed Mar 3 11:06:16 PST 2010
Hi Andrew,
Thanks for the suggestion... I agree that's the issue, but I'm not
quite sure how to work around it. I've tried the following to no avail
- how do I replace the & with &? (unfortunately, I can't change the
value of $ex, this comes from web-service call)...
let $ex as xs:string := '<exception message="One of
''{"http://www.w3.org/1998/Math/MathML":semantics}'' is
expected."/>'
return
xdmp:unquote(
replace($ex, "&", "&")
)
On 3/3/2010 1:55 PM, Andrew Welch wrote:
> 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
>> ''{"http://www.w3.org/1998/Math/MathML":semantics}'' is
>> expected."/>'
>> return xdmp:unquote($ex)
>>
>> Always gives error "SystemID: XDMP-DOCSTARTTAGCHAR: xdmp:unquote("<exception
>> message="One of '{"http://www.w3.org/1998/M...") -- Unexpected
>> character "/" in start tag at line 1"
>>
> That's because" 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 ''{&quot;
>
> ..then after the query is parsed you are left with """ as expected.
>
> cheers
> andrew
>
>
>
More information about the General
mailing list