有个xml文档,
里面的Content是一个CDATA,
使用xslt <xsl:value-of select="Content" />CDATA内容时显示转译过的文本,既显示"<"和">"
结果在网上找了大半个晚上,原来只要 加上 disable-output-escaping ="yes" 搞定.
Xml内容
Xslt内容
里面的Content是一个CDATA,
使用xslt <xsl:value-of select="Content" />CDATA内容时显示转译过的文本,既显示"<"和">"
结果在网上找了大半个晚上,原来只要 加上 disable-output-escaping ="yes" 搞定.
Xml内容
<?
xml version="1.0" encoding="UTF-8" standalone="no"
?>
<? xml-stylesheet type="text/xsl" href="/Web/Template/Common/Comments.xslt" ?>
< Root ShopID ="2" pubDate ="2006-12-21 17:34:00" >
< Comment id ="27" pubDate ="2006-12-21 17:34:04" >
< Title > texcxc cvcv </ Title >
< Poster > 匿名 </ Poster >
< Content > <![CDATA[ sxxxxx xxxxx<br />xxxx<b>xxxxx<b>xcxccccccccccc
<span>cccccc</span>cccccccccccccccccccccccccc ]]> </ Content >
</ Comment >
< Comment id ="1" pubDate ="2006-12-20 20:53:25" >
< Title > Test One </ Title >
< Poster > 匿名 </ Poster >
< Content > <![CDATA[ null null null ]]> </ Content >
</ Comment >
</ Root >
<? xml-stylesheet type="text/xsl" href="/Web/Template/Common/Comments.xslt" ?>
< Root ShopID ="2" pubDate ="2006-12-21 17:34:00" >
< Comment id ="27" pubDate ="2006-12-21 17:34:04" >
< Title > texcxc cvcv </ Title >
< Poster > 匿名 </ Poster >
< Content > <![CDATA[ sxxxxx xxxxx<br />xxxx<b>xxxxx<b>xcxccccccccccc
<span>cccccc</span>cccccccccccccccccccccccccc ]]> </ Content >
</ Comment >
< Comment id ="1" pubDate ="2006-12-20 20:53:25" >
< Title > Test One </ Title >
< Poster > 匿名 </ Poster >
< Content > <![CDATA[ null null null ]]> </ Content >
</ Comment >
</ Root >
Xslt内容
<?
xml version="1.0" encoding="utf-8"
?>
< xsl:stylesheet version ="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" >
< xsl:output method ="html" />
< xsl:template match ="/" >
< xsl:element name ="div" >
< xsl:attribute name ="id" > Comments_lists </ xsl:attribute >
< table width ="100%" border ="0" cellpadding ="3" cellspacing ="0" >
< xsl:for-each select ="Root/Comment" >
< tr class ="trW" >
< xsl:if test ="position() mod 2=0" >
< xsl:attribute name ="class" > trW bgG </ xsl:attribute >
</ xsl:if >
< td align ="center" style ="width: 152px;" >
< strong >
< xsl:value-of select ="Poster" />
</ strong >
< br />
< xsl:value-of select ="@pubDate" />
</ td >
< td align ="left" class ="tdBDotMessage" style ="word-wrap:break-word ;word-break:break-all;" >
< xsl:value-of select ="Content" disable-output-escaping ="yes" />
</ td >
</ tr >
</ xsl:for-each >
< xsl:if test ="count(Root/Comment) < 1" >
< tr class ="trW" >
< xsl:if test ="position() mod 2=0" >
< xsl:attribute name ="class" > trW bgG </ xsl:attribute >
</ xsl:if >
< td class ="tdBDot tdBDotMessage" height ="88" align ="center" > 没有相关评论! </ td >
</ tr >
</ xsl:if >
</ table >
</ xsl:element >
</ xsl:template >
</ xsl:stylesheet >
< xsl:stylesheet version ="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" >
< xsl:output method ="html" />
< xsl:template match ="/" >
< xsl:element name ="div" >
< xsl:attribute name ="id" > Comments_lists </ xsl:attribute >
< table width ="100%" border ="0" cellpadding ="3" cellspacing ="0" >
< xsl:for-each select ="Root/Comment" >
< tr class ="trW" >
< xsl:if test ="position() mod 2=0" >
< xsl:attribute name ="class" > trW bgG </ xsl:attribute >
</ xsl:if >
< td align ="center" style ="width: 152px;" >
< strong >
< xsl:value-of select ="Poster" />
</ strong >
< br />
< xsl:value-of select ="@pubDate" />
</ td >
< td align ="left" class ="tdBDotMessage" style ="word-wrap:break-word ;word-break:break-all;" >
< xsl:value-of select ="Content" disable-output-escaping ="yes" />
</ td >
</ tr >
</ xsl:for-each >
< xsl:if test ="count(Root/Comment) < 1" >
< tr class ="trW" >
< xsl:if test ="position() mod 2=0" >
< xsl:attribute name ="class" > trW bgG </ xsl:attribute >
</ xsl:if >
< td class ="tdBDot tdBDotMessage" height ="88" align ="center" > 没有相关评论! </ td >
</ tr >
</ xsl:if >
</ table >
</ xsl:element >
</ xsl:template >
</ xsl:stylesheet >