Ignore that - I hadn't grasped the problem. Sorry for the general confusion.

If the web service is returning valid xml, then there shouldn't be a problem with xdmp:unquote(). The quotes should be &quote; in the actual string from the web service. You should also be able to use the xdmp:document-get 'format' option to specify xml in the first place.

You should only need '&quote;' if you're trying to test sample output in cq (or another ad-hoc query evaluator). And for test cases like that, you should be able to modify the string as needed.

Here's a replace() that does work, but it's problematic. As far as the evaluator and the XQuery data model are concerned, there is no difference between <p>"</p> and <p>&quote;</p>. So the regex has to look for other clues to figure out which one you want to replace.

let $ex as xs:string :=
'<exception message="One of ''{&quot;http://www.w3.org/1998/MathMathML&quot;:semantics}'' is expected."/>'
let $ex := replace($ex, '\{"', '{&amp;quot;')
let $ex := replace($ex, '":', '&amp;quot;:')
return xdmp:unquote($ex)
=>
<exception message="One of '{&quot;http://www.w3.org/1998/MathMathML&quot;:semantics}' is expected."/>

-- Mike

On 2010-03-03 11:14, Michael Blakeley wrote:
Wyatt,

Try using a computed constructor.

let $message := 'this is a string with a "quote" inside it'
return element exception {
    attribute message { $message }
}
=>
<exception message="this is a string with a&quot;quote&quot; inside it"/>

-- Mike

On 2010-03-03 11:06, Wyatt VanderStucken wrote:
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&amp;? (unfortunately, I can't change the
value of $ex, this comes from web-service call)...

let $ex as xs:string := '<exception message="One of
''{&quot;http://www.w3.org/1998/Math/MathML&quot;:semantics}'' is
expected."/>'
return
       xdmp:unquote(
           replace($ex, "&","&amp;")
       )


On 3/3/2010 1:55 PM, Andrew Welch wrote:
On 3 March 2010 18:31, Wyatt VanderStucken<[email protected]>    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




_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general


_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to