Hi,
I've done something similar (I think) in BaseX using the serialize() function (XPath 3.0). It was easy enough that I suspect I don't understand the requirement here. As Christian points out, XML doesn't allow you to represent XML directly in an attribute value; I used an element.
When using the text output method it comes out as XML (because it's already been serialized). When using the XML output method, it comes out escaped (as it should be).
Cheers, Wendell Wendell Piez | http://www.wendellpiez.com XML | XSLT | electronic publishing Eat Your Vegetables _____oo_________o_o___ooooo____ooooooo_^
On Thu, Dec 5, 2013 at 4:04 PM, Joe Templeman joe@inkling.com wrote:
Ah that makes sense. Is there no way then to return a message from a unittest which contains XML? The framework creates the <failure> blocks based on the result of assertions so I don't have control over what is displayed it seems.
On Thu, Dec 5, 2013 at 12:56 PM, Christian Grün christian.gruen@gmail.com wrote:
Hi Joe,
<testcase name="test-element-info" time="PT0.011S"> <failure message="Failed input Input: input Expected: output Got: {removed}" type="UNIT0001"/> </testcase>
What I would like is ".. Expected: <result>output</result> ..." since what is being returned is XML.
This is syntactically not possible, because "<" cannot occur in attribute values. The following XML is not well-formed:
<x a="<"/>
However, it’s possible to output the value of an attribute as string, and then skip the entity encoding:
declare option output:method "text"; let $expected := serialize(<a/>) let $xml := <failure message="Expected: { $expected }"/> return $xml/@message/string()
Hope this helps, Christian
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk