Note that there are some explanatory texts on larger screens.

plurals
  1. POXSL transformation and special XML entities escaping
    text
    copied!<p>I have an XML file which is transformed with XSL. Some elements have to be changed, some have to be left as is - specifically, text with entities <strong>&amp;quot;</strong>, <strong>&amp;amp;</strong>, <strong>&amp;apos;</strong>, <strong>&amp;lt;</strong>, <strong>&amp;gt;</strong> should be left as is, and in my case <strong>&amp;quot;</strong> and <strong>&amp;apos;</strong> are changed to <strong>&quot;</strong> and <strong>&apos;</strong> accordingly.</p> <p>Test XML:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;root&gt; &lt;element&gt; &amp;quot; &amp;amp; &amp;apos; &amp;lt; &amp;gt; &lt;/element&gt; &lt;/root&gt; </code></pre> <p>transformation file:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt; &lt;xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="no" /&gt; &lt;xsl:template match="element"&gt; &lt;xsl:copy&gt; &lt;xsl:value-of disable-output-escaping="no" select="." /&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>result:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;element&gt; " &amp;amp; ' &amp;lt; &amp;gt; &lt;/element&gt; </code></pre> <p>desired result:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;element&gt; &amp;quot; &amp;amp; &amp;apos; &amp;lt; &amp;gt; &lt;/element&gt; </code></pre> <p>I have 2 questions:</p> <ul> <li>why does some of those entities are transformed and other not?</li> <li>how can I get a desired result?</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload