I'm trying to produce CDATA sections from the code in XML transformers. I'm unable to this with the following code (only plain text is outputed):
object AddCDATATransformer extends RewriteRule {
override def transform(n: Node): Seq[Node] = n match {
case n: Text => scala.xml.PCData(n.text)
case _ => n
}
}
Strangely enough this succeeds :
n.copy(child = scala.xml.PCData(v) ++ n.child.tail)
Can someone explain this? How to get consistent results?
PS. I googled out that there is some
-Xxml:coalescing
flag but cannot find any documentation on how to use it.