Hi Wyatt, I don't recommend using replace like that. And since I guess you will have little control on how the exceptions are formatted, I recommend letting go of xdmp:quote and xdmp:unquote all together and using xdmp:value instead of xdmp:eval. Using xdmp:value you can refer to variables from the context. You could also pass them explicitly to xdmp:value, but then you would have to define them in the subquery as external variables, which is rather awkward..
Kind regards, Geert ________________________________ From: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] On Behalf Of Wyatt VanderStucken Sent: woensdag 3 maart 2010 19:56 To: general@developer.marklogic.com Subject: Re: [MarkLogic Dev General] Escaping text? Hi Geert, Thanks for responding... Yes, this is really part of a much larger XQuery, this snippit just illustrates where I'm stuck. The value of $ex originates from a web-service call, which we use to create a which we then feed into xdmp:eval() - something like this... let $status := <status><exception message="xxxx"/></status>, $error := <errorConditions> <errorCondition message="Missing key(s). Please supply key(s) for this item and save or validate again."> <condition xpath="string(@message)='java.lang.Exception: integer_key (null) is not an integer'"<mailto:string(@message)='java.lang.Exception:integer_key(null)isnotaninteger'>/> <condition xpath="string(@message)='cvc-complex-type.4: Attribute ''value'' must appear on element ''integer_key''.'"<mailto:string(@message)='cvc-complex-type.4:Attribute''value''mustappearonelement''integer_key''.'>/> </errorCondition> <errorCondition message="Missing key(s). Please supply key(s) for this item and save or validate again."> <condition xpath="string(@message)='cvc-complex-type.4: Attribute ''value'' must appear on element ''integer_key''.'"<mailto:string(@message)='cvc-complex-type.4:Attribute''value''mustappearonelement''integer_key''.'>/> </errorCondition> </errorConditions>, $quotedStatus as xs:string := replace(xdmp:quote($status), "'", "''"), $matchedExceptions as element()* := for $errorCondition as element() in $errorConditions/errorCondition let $conditions as element()* := $errorCondition/condition, $combinedXpath as xs:string := concat("xdmp:unquote('", $quotedStatus, "')", "/status/exception[", string-join( for $condition as element() in $conditions return string($condition/@xpath), " and " ), "]") return xdmp:eval($combinedXpath) return doSomeThingWithData($quotedStatus, $matchedExceptions) On 3/3/2010 1:39 PM, Geert Josten wrote: Hi Wyatt, Do you have to use xdmp:unquote for a particular reason? Otherwise you could do something like this: <exception message="one of '{{"http://www.w3.org/1998/Math/MathML":semantics}}' is expected."/> Kind regards, Geert drs. G.P.H. (Geert) Josten Consultant Daidalos BV Hoekeindsehof 1-4 2665 JZ Bleiswijk T +31 (0)10 850 1200 F +31 (0)10 850 1199 mailto:geert.jos...@daidalos.nl http://www.daidalos.nl/ KvK 27164984 P Please consider the environment before printing this mail. De informatie - verzonden in of met dit e-mailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend. From: general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com> [mailto:general-boun...@developer.marklogic.com] On Behalf Of Wyatt VanderStucken Sent: woensdag 3 maart 2010 19:32 To: General Mark Logic Developer Discussion Subject: [MarkLogic Dev General] Escaping text? 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" I've tried a variety fn:replace calls, but haven't yet found the magic... Thanks, Wyatt _______________________________________________ General mailing list General@developer.marklogic.com<mailto:General@developer.marklogic.com> http://xqzone.com/mailman/listinfo/general
_______________________________________________ General mailing list General@developer.marklogic.com http://xqzone.com/mailman/listinfo/general