views:

109

answers:

2

Hi all. I am really stuck here. 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!!

A: 

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>...

Yousuf
yes, as i stated above, i inserted the blank to allow me to show that it is not working properly. If i remove the blank, it looks like it is working (for rendering on this site)
Mark
A: 

you need to pass the whole CDATA block to yieldUnescaped

 mkp.yieldUnescaped( "<![CDATA[.....
objects