Producing CDATA sections with XML transformers

Zephod <[email protected]> Wed, 3 Aug 2016 08:24:06 -0700 (PDT)
Newsgroups gmane.comp.lang.scala
Message-ID <[email protected]>
------=_Part_4924_1190232877.1470237846916
Content-Type: multipart/alternative; 
	boundary="----=_Part_4925_1266591777.1470237846916"

------=_Part_4925_1266591777.1470237846916
Content-Type: text/plain; charset=UTF-8

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.

-- 
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

------=_Part_4925_1266591777.1470237846916
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I&#39;m trying to produce CDATA sections from the code in =
XML transformers. I&#39;m unable to this with the following code (only plai=
n text is outputed):<br><br><pre style=3D"" class=3D"default prettyprint pr=
ettyprinted"><span style=3D"font-family: courier new,monospace;"><code><spa=
n class=3D"kwd">object</span><span class=3D"pln"> </span><span class=3D"typ=
">AddCDATATransformer</span><span class=3D"pln"> </span><span class=3D"kwd"=
>extends</span><span class=3D"pln"> </span><span class=3D"typ">RewriteRule<=
/span><span class=3D"pln"> </span><span class=3D"pun">{</span><span class=
=3D"pln">
  </span><span class=3D"kwd">override</span><span class=3D"pln"> </span><sp=
an class=3D"kwd">def</span><span class=3D"pln"> transform</span><span class=
=3D"pun">(</span><span class=3D"pln">n</span><span class=3D"pun">:</span><s=
pan class=3D"pln"> </span><span class=3D"typ">Node</span><span class=3D"pun=
">):</span><span class=3D"pln"> </span><span class=3D"typ">Seq</span><span =
class=3D"pun">[</span><span class=3D"typ">Node</span><span class=3D"pun">]<=
/span><span class=3D"pln"> </span><span class=3D"pun">=3D</span><span class=
=3D"pln"> n match </span><span class=3D"pun">{</span><span class=3D"pln">
    </span><span class=3D"kwd">case</span><span class=3D"pln"> n</span><spa=
n class=3D"pun">:</span><span class=3D"pln"> </span><span class=3D"typ">Tex=
t</span><span class=3D"pln"> </span><span class=3D"pun">=3D&gt;</span><span=
 class=3D"pln"> scala</span><span class=3D"pun">.</span><span class=3D"pln"=
>xml</span><span class=3D"pun">.</span><span class=3D"typ">PCData</span><sp=
an class=3D"pun">(</span><span class=3D"pln">n</span><span class=3D"pun">.<=
/span><span class=3D"pln">text</span><span class=3D"pun">)</span><span clas=
s=3D"pln">
    </span><span class=3D"kwd">case</span><span class=3D"pln"> _ </span><sp=
an class=3D"pun">=3D&gt;</span><span class=3D"pln"> n
  </span><span class=3D"pun">}</span><span class=3D"pln">
</span><span class=3D"pun">}</span></code></span></pre><br>Strangely enough=
 this succeeds :<br><br>n.copy(child =3D scala.xml.PCData(v) ++ n.child.tai=
l)<br><br>Can someone explain this? How to get consistent results?<br><br>P=
S. I googled out that there is some <code>-Xxml:coalescing</code> flag but =
cannot find any documentation on how to use it.<br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;scala-language&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">scal=
[email protected]</a>.<br />
For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
s://groups.google.com/d/optout</a>.<br />

------=_Part_4925_1266591777.1470237846916--

------=_Part_4924_1190232877.1470237846916--