redundent / kotlin-xml-builder

A lightweight type safe builder to build xml documents in Kotlin
Apache License 2.0
155 stars 19 forks source link

Make CData whitespace and nesting work together #15

Closed TWiStErRob closed 5 years ago

TWiStErRob commented 5 years ago

This PR is what I meant in https://github.com/redundent/kotlin-xml-builder/pull/12#issuecomment-463862604, but don't know how to implement it. Feel free to close this if you don't want to do this.

redundent commented 5 years ago

Hmm, that's a tricky one since the xml parser sees it as 2 separate CData elements but with prettyPrint on, it throws in an extra line break.

I think this should be fixable. I'll mess around with it a bit tomorrow

redundent commented 5 years ago

I got your test working but the code is ugly and I don't really like how I had to do it.

The parsing part of the library was added a more of a convenience function to handle fairly simple xml documents. I'm tempted to file this one under "won't fix."

Is parsing nested CDATA elements blocking you from fully using the library?

TWiStErRob commented 5 years ago

no, I'm not parsing nested CDATA for now feel free to wontfix. I was only outputting XML code that may already contain CDATA for XSLT transformation.

In the meantime I'm actually moving away from your library because I need streaming XML output (large amounts of data can't fit into StringBuilder).

Re #13: it turns out that the standard Java 8 XMLStreamWriter doesn't handle writeCData("<![CDATA[...]]>") either.