mkp.yieldUnescaped not working
I am really stuck he开发者_Python百科re. I am creating an XML document with Groovy 1.7 and everything is working except one section is being escaped when it shouldn't.
I am starting out like this:
triadDoc = new XmlSlurper().parse(xmlTriadMessageDocumentPath)
writer = new StringWriter()
xmlBuilder = new StreamingMarkupBuilder()
writer = xmlBuilder.bind {mkp.yield triadDoc}
which works great. Then I'm adding to the document like this:
triadDoc.TriadPayload.Payload[0] = "<![CDATA[" + xmlBuilder.bind {mkp.yieldUnescaped dto.getCcdDoc()} + "]]>"
This does not work as I want - I end up with this:
& lt;![CDATA[& lt;ClinicalDocument& gt;... (added extra blank to the escape sequences)
Can anyone tell me what I'm doing wrong? I've looked all over the Internet for a clue. Thanks!!
you need to pass the whole CDATA block to yieldUnescaped
mkp.yieldUnescaped( "<![CDATA[.....
NOTE: The CDATA section in a document is ignored by a parser.
maybe that is what is causing this thing to skip.
the four characters need to be together inorder to get you the '<' and '>' values.
<![CDATA[<ClinicalDocument>...
精彩评论