If the string with the & is outside of marklogic,
your examples probably do not do what you think they are doing because they
are running from within XQuery which itself is doing funny things with &.

Could you back up a step and explain how the data is arriving at the system ?
Is it XML to start with ? Is it valid XML ?
If it is not valid xml to start with it needs to be fixed prior to getting into 
marklogic (atleast prior to getting in an XML node - you could import it as 
text).




-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]
Phone: +1 812-482-5224
Cell:  +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>


From: [email protected] 
[mailto:[email protected]] On Behalf Of David Scott Gurney
Sent: Friday, October 05, 2012 5:04 PM
To: [email protected]
Subject: [MarkLogic Dev General] xdmp:unquote and ampersand

I have a need to convert a string that has an ampersand into xml and I can't 
get it to work. I have tried encoding the ampersand, but none of them seem to 
work. The string is coming from a system external to MarkLogic and it can be 
changed (if that will help).

xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";;

(:let $testString1 := "<root>foo & bar</root>":)
let $testString2 := "<root>foo &amp; bar</root>"
let $testString3 := "<root>foo &#38; bar</root>"
let $testString4 := "<root>foo %26 bar</root>"
let $testString5 := "&lt;root&gt;foo &amp; bar&lt;/root&gt;"
let $testString6 := "&lt;root&gt;foo &#38; bar&lt;/root&gt;"
let $testString7 := "&lt;root&gt;foo %26 bar&lt;/root&gt;"
return xdmp:unquote($testString5)


Maybe there is another way to convert the string into xml?

I'm using MarkLogic 5.0-3.3

Thanks
David
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to