Firstly, they aren't called metacharacters - they are called entity references.
Secondly, you don't say why it's essential that they are preserved. Any XML parser treats " and " as equivalent. Does this mean that you are reading the XML with something other than an XML parser? If so, why?
Thirdly, if you want to control this using character-map, you can do so. If you specify the target string as " (which is written ") then it will be output as ". If you specify the target string as " (which is written ") then it will be output as ".
Michael Kay

From: [] On Behalf Of Johnson, Wayne
Sent: 28 March 2004 04:55
Subject: [saxon] expansion of XML metacharacters

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() | @*"/>