Prevent Ampersand Escaping

"Friessen, Michelle" <[email protected]> Tue, 14 Jan 2014 11:13:46 -0600
Newsgroups gmane.text.xml.xmlbeans.user
Message-ID <CANm+gpER45k1GrrChOEPXuHif=FvWtpH4O-EwY4LNjpau1kesw@mail.gmail.com>
--f46d0435c068ad02d004eff150ac
Content-Type: text/plain; charset=ISO-8859-1

Greetings,

Is there any way to stop XMLBeans version 2.5.0 from escaping the
ampersand?  Per system requirements, I am converting special characters as
follows:

return str.replace("&", "&#x0026;").replace("\"", "&#x0022;").replace("'",
"&#x0027;").replace("<", "&#x003C;").replace(">", "&#x003E;");

However, xmlbeans is escaping the ampersand (&#x0022; becomes &amp;x0022;);
therefore, the character comes out as code (&amp;#x0026; instead of &) when
the XML is read by another application.

XmlOptionCharEscapeMap does not have the capability to handle the codes I
need to use.  When I specify

escapes.addMapping('&', XmlOptionCharEscapeMap.HEXADECIMAL);

the ampersand comes out as &amp; instead of &#x26;.

It's likely that someone is going to respond saying xmlbeans has to escape
the ampersand because it is a mandatory restriction of XML.  If that is a
response, then please provide some type of solution to my problem because I
have to use the codes listed above.

Thanks.

-- Michelle

--f46d0435c068ad02d004eff150ac
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Greetings,</div><div><br></div><div>Is there any way =
to stop XMLBeans version 2.5.0 from escaping the ampersand? =A0Per system r=
equirements, I am converting special characters as follows:</div><div><br><=
/div>
<div>return str.replace(&quot;&amp;&quot;, &quot;&amp;#x0026;&quot;).replac=
e(&quot;\&quot;&quot;, &quot;&amp;#x0022;&quot;).replace(&quot;&#39;&quot;,=
 &quot;&amp;#x0027;&quot;).replace(&quot;&lt;&quot;, &quot;&amp;#x003C;&quo=
t;).replace(&quot;&gt;&quot;, &quot;&amp;#x003E;&quot;);<br>
</div><div><br></div><div>However, xmlbeans is escaping the ampersand (&amp=
;#x0022; becomes &amp;amp;x0022;); therefore, the character comes out as co=
de (&amp;amp;#x0026; instead of &amp;) when the XML is read by another appl=
ication.</div>
<div><br></div><div>XmlOptionCharEscapeMap does not have the capability to =
handle the codes I need to use. =A0When I specify</div><div><br></div><div>=
escapes.addMapping(&#39;&amp;&#39;, XmlOptionCharEscapeMap.HEXADECIMAL);</d=
iv>
<div><br></div><div>the ampersand comes out as &amp;amp; instead of &amp;#x=
26;.</div><div><br></div><div>It&#39;s likely that someone is going to resp=
ond saying xmlbeans has to escape the ampersand because it is a mandatory r=
estriction of XML. =A0If that is a response, then please provide some type =
of solution to my problem because I have to use the codes listed above.</di=
v>
<div><br></div><div>Thanks.</div><div><br></div><div><div>-- Michelle</div>=
</div>
</div>

--f46d0435c068ad02d004eff150ac--