My application is performing a series of XML to XML transformations. It is essential that the &quot; and &apos; metacharacters be preserved after each transformation. However, I find that while the < > & characters are expanded, saxon (and xalan) will not expand the ‘ “  characters in the output serialization. If character maps (or entity property files) are used, the mappings have the effect of turning off the expansion for the XML metacharacters. For example, if I create a mapping from &#62; to &lt; the output element will contain the < character, not the &lt; I expect. (The mappings work as advertised for characters that are not XML metacharacters.)


What is the reason for this behavior and what is the simplest way to ensure that the five XML metacharacters will be expanded?


Wayne Johnson


saxon 7.9.1


input file


<e1> &apos; &lt; &gt; &amp; &quot; </e1>

<e2> &#65; </e2>



output file

<?xml version="1.0" encoding="UTF-8"?>


   <e1> ' < &gt; &amp; " </e1>

   <e2> AAA </e2>




<xsl:stylesheet version="2.0"







  <xsl:strip-space elements="*"/>


  <xsl:character-map name="mycharmap">

<!--    <xsl:output-character character="&#34;" string="&quot;"/>-->

<!--    <xsl:output-character character="&#38;" string="&amp;"/>-->

<!--    <xsl:output-character character="&#39;" string="&apos;"/>-->

    <xsl:output-character character="&#60;" string="&lt;"/>

<!--    <xsl:output-character character="&#62;" string="&gt;"/>-->

    <xsl:output-character character="&#65;" string="AAA"/>



  <xsl:template match="node() | @*">


      <xsl:apply-templates select="node() | @*"/>