xsl trying to ouput '<' as opposed to '&lt;'

dudledok picture dudledok · Jul 12, 2011 · Viewed 23.9k times · Source

Update:

The issue still persists although it is not quite the same as before. Below is an example of what is being input, what is being output and what I want to have output

An example of the input:

&amp;lt;p&amp;gt;&amp;lt;span style=&amp;quot;font-size: medium&amp;quot;&amp;gt;Product description text&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;

Current output:

&lt;p&gt;&lt;span style="font-size: medium"&gt;Product description text&lt;/span&gt;&lt;/p&gt;

Intended output:

<p><span style="font-size: medium">Product description text</span></p>

.

Using CDATA has helped as it allows me to input '<' but as seen in the output above, even when using disable-output-escaping, it has changed in the output

.

.

Original question:

The error I'm getting is "'<', hexadecimal value 0x3C, is an invalid attribute character"

What I'm trying to do is replace all occurrences of &lt ; and &gt ; with < and > respectively.

To keep this as simple as possible, here is the code for just lt;:

<xsl:variable name="lt">
  <xsl:text><</xsl:text>
</xsl:variable>
<xsl:variable name="lthex">&amp;lt;</xsl:variable>
<xsl:copy-of select="ew:replacestring(products_description/node(),$lthex,$lt)"/>

I've tried various things in place of text e.g. value-of etc.

I know there's nothing wrong with the code format and the vb code linked to it because I'm using it multiple times to replace and output elsewhere

The problem with this though is that I want < and > to literally be ouput, not a code which is then seen by the browser and changed

.

If you need more information just ask (I'm struggling to explain this very well)

Any help will be appreciated

Answer

Emiliano Poggi picture Emiliano Poggi · Jul 12, 2011
<xsl:text disable-output-escaping="yes"><![CDATA[<]]></xsl:text>

This is because < is illegal (and that's why your app is complaining). For >, you can use:

<xsl:text disable-output-escaping="yes">></xsl:text>