Xslt直接显示CDATA内容

有个xml文档,
里面的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 >

 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) &lt; 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 >
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值