Question

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

Was it helpful?

Solution

you need to pass the whole CDATA block to yieldUnescaped

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top