Producing CDATA sections with XML transformers

34 views
Skip to first unread message

Zephod

unread,
Aug 3, 2016, 11:24:07 AM8/3/16
to scala-language
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.
Reply all
Reply to author
Forward
0 new messages