Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's definitely not pretty, but basically you are looking at a limited number of string replace operations</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="html" encoding="utf-8" /&gt; &lt;xsl:variable name="ampDbl" select="'&amp;amp;amp;'" /&gt; &lt;xsl:variable name="amp" select="'&amp;amp;'" /&gt; &lt;xsl:variable name="ltDbl" select="'&amp;amp;lt;'" /&gt; &lt;xsl:variable name="lt" select="'&amp;lt;'" /&gt; &lt;xsl:variable name="gtDbl" select="'&amp;amp;gt;'" /&gt; &lt;xsl:variable name="gt" select="'&amp;gt;'" /&gt; &lt;xsl:template match="/"&gt; &lt;xsl:apply-templates select="//@data" mode="unescape" /&gt; &lt;/xsl:template&gt; &lt;xsl:template match="@data" mode="unescape"&gt; &lt;xsl:variable name="step1"&gt; &lt;xsl:call-template name="StringReplace"&gt; &lt;xsl:with-param name="s" select="string()" /&gt; &lt;xsl:with-param name="search" select="$ltDbl" /&gt; &lt;xsl:with-param name="replace" select="$lt" /&gt; &lt;/xsl:call-template&gt; &lt;/xsl:variable&gt; &lt;xsl:variable name="step2"&gt; &lt;xsl:call-template name="StringReplace"&gt; &lt;xsl:with-param name="s" select="$step1" /&gt; &lt;xsl:with-param name="search" select="$gtDbl" /&gt; &lt;xsl:with-param name="replace" select="$gt" /&gt; &lt;/xsl:call-template&gt; &lt;/xsl:variable&gt; &lt;xsl:variable name="step3"&gt; &lt;xsl:call-template name="StringReplace"&gt; &lt;xsl:with-param name="s" select="$step2" /&gt; &lt;xsl:with-param name="search" select="$ampDbl" /&gt; &lt;xsl:with-param name="replace" select="$amp" /&gt; &lt;/xsl:call-template&gt; &lt;/xsl:variable&gt; &lt;xsl:value-of select="$step3" disable-output-escaping="yes" /&gt; &lt;/xsl:template&gt; &lt;!-- generic string replace template --&gt; &lt;xsl:template name="StringReplace"&gt; &lt;xsl:param name="s" select="''" /&gt; &lt;xsl:param name="search" select="''" /&gt; &lt;xsl:param name="replace" select="''" /&gt; &lt;xsl:choose&gt; &lt;xsl:when test="contains($s, $search)"&gt; &lt;xsl:value-of select="substring-before($s, $search)" /&gt; &lt;xsl:value-of select="$replace" /&gt; &lt;xsl:variable name="rest" select="substring-after($s, $search)" /&gt; &lt;xsl:if test="$rest"&gt; &lt;xsl:call-template name="StringReplace"&gt; &lt;xsl:with-param name="s" select="$rest" /&gt; &lt;xsl:with-param name="search" select="$search" /&gt; &lt;xsl:with-param name="replace" select="$replace" /&gt; &lt;/xsl:call-template&gt; &lt;/xsl:if&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="$s" /&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>When applied to</p> <pre><code>&lt;root&gt; &lt;node data="&amp;amp;lt;div&amp;amp;gt;bla &amp;amp;amp;amp; bla&amp;amp;lt;/div&amp;amp;gt;" /&gt; &lt;/root&gt; </code></pre> <p>gives (in source code)</p> <pre><code>&lt;div&gt;bla &amp;amp; bla&lt;/div&gt; </code></pre> <p>which of course becomes this on screen:</p> <pre>bla &amp; bla</pre> <p>You might want to add a <code>step4</code> for <code>'&amp;amp;quot;'</code> to <code>'&amp;quot;'</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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