0

I'm transforming an XML-Document to an XML-Document. The output of this instruction:

<xsl:value-of select="'a&#8198;2'"/>

should be:

..>a&#8198;2<...

The current output is:

a 2

So the entity is interpreted. How can I escape it?

I tried

  1. \ 
  2. / 
  3. concat('a', ' ', '2')

4.

   <xsl:character-map name="entities">
        <xsl:output-character character="&#8198;" string="&#8198;"/>
    </xsl:character-map>


   <xsl:output encoding="UTF-8" indent="yes" method="xml" use-character-maps="entities"/>

For the transformation I use Oxygen 20.1 with embedded Saxon EE 9.8.0.12

o-sapov
  • 320
  • 2
  • 13
  • 1
    I've chosen one particular question as a duplicate of this, but if you search for "XSLT preserve entities" you will find many other similar questions and answers, and I think that between them, they should give you all the information you need. – Michael Kay Mar 26 '19 at 10:21
  • That particular answer was different as my problem as I don't handle the entities declared in the stylesheet; I checked it before, also the few others. Eventually, the solution provided my @imran was a simple one. – o-sapov Mar 26 '19 at 17:10
  • Yes, I should have checked more carefully. Your question isn't actually about entities at all, it is about character references; you're not alone in referring to these incorrectly as entities. – Michael Kay Mar 26 '19 at 20:09
  • yes. sorry. Is it possible then to revert the duplication of this question :) – o-sapov Mar 27 '19 at 08:32
  • I've re-opened it. It's actually a duplicate of https://stackoverflow.com/questions/13006514/how-can-i-preserve-html-entities-with-diazo but I'm not allowed to re-close it. – Michael Kay Mar 27 '19 at 09:09

1 Answers1

0
In Character map you should use
 <xsl:character-map name="entities">
        <xsl:output-character character="&#8198;" string="&amp;#8198;"/>
    </xsl:character-map>
Instead
<xsl:output-character character="&#8198;" string="&#8198;"/>
imran
  • 461
  • 4
  • 8