XSLT displays & gt; and & lt; for> <how do I get around this?

I have code wrapped in a CDATA tag in an xslt file:

 <span>
   <xsl:text><![CDATA[<asp:LinkButton ID ="]]></xsl:text><xsl:value-of select="ID"/>
   <xsl:text><![CDATA[" onclick="LinkClicked">]]></xsl:text >

   <xsl:value-of select="."/>
   <xsl:text><![CDATA[</asp:LinkButton>]]></xsl:text>
 </span> 

When it displays on the page &gt;and &lt;how do I get around this?

Now I know how to work, since I can do a replacement inside the string after it is shown, but this does not seem to be the best approach.

+3
source share
3 answers

You need to change the XSLT code:

<span>
  <asp:LinkButton ID="{ID}" onclick="LinkClicked">
    <xsl:value-of select="."/>
  </asp:LinkButton>
</span> 

All this CDATA juggling is not only bad for all eyes, but also the wrong approach, no matter how you look at it.

Declare the namespace aspin XSLT and use the actual ASP.NET code, not text that looks like code.

+6

, .net.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:asp="remove">

xmlns: asp = "remove"

xsl: text cdata.

+2

Why are you exchanging a tag for CDATA? The behavior you describe is exactly what you expect, so people use CDATA for content that they want to avoid.

+2
source

Source: https://habr.com/ru/post/1733177/


All Articles