以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML基础 』  (http://bbs.xml.org.cn/list.asp?boardid=1)
----  怎样写xslt,数据库中的换行和空格,现在我的树中一旦有空格就显示加载错误  (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=43256)


--  作者:longwaytec
--  发布时间:2/13/2007 1:27:00 PM

--  怎样写xslt,数据库中的换行和空格,现在我的树中一旦有空格就显示加载错误
<?xml version="1.0"  encoding="gb2312"?>           
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="xml/TreeNode">
<div class="Node">
<xsl:attribute name="uid"><xsl:value-of select="@id"/></xsl:attribute>
<nobr>
<img type="icon" align="absmiddle">
<xsl:attribute name="id">icon<xsl:value-of select="@id"/></xsl:attribute>
<xsl:attribute name="src">
<xsl:choose>
<xsl:when test="child[. &gt; 0]">images/collapsed.gif</xsl:when>
<xsl:otherwise>images/endnode.gif</xsl:otherwise></xsl:choose></xsl:attribute>
</img><span type="Node" style="margin-left:3px">
<xsl:attribute name="title">
<xsl:choose>
<xsl:when test="title[. != '']"><xsl:value-of disable-output-escaping="yes" select="title"/></xsl:when>
<xsl:otherwise><xsl:value-of disable-output-escaping="yes" select="NodeText"/></xsl:otherwise></xsl:choose>
</xsl:attribute>
<xsl:if test="NodeUrl[. != '']">
<xsl:attribute name="url"><xsl:value-of disable-output-escaping="yes" select="NodeUrl"/></xsl:attribute>
<xsl:attribute name="target">
<xsl:choose>
<xsl:when test="target[. != '']"><xsl:value-of disable-output-escaping="yes" select="target"/></xsl:when>
<xsl:otherwise>main</xsl:otherwise></xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="id">Node<xsl:value-of select="@id"/></xsl:attribute>
<xsl:value-of disable-output-escaping="yes" select="NodeText"/>
</span></nobr>
</div>
<xsl:if test="child[. &gt; 0]">
<div style="padding-left:12;display:none">
<xsl:attribute name="id">Child<xsl:value-of select="@id"/></xsl:attribute>
<div class="Node"><nobr><img src="images/endnode.gif" align="absmiddle"/><span class="NodeLoad">正在载入数

据...</span></nobr></div>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>


--  作者:Qr
--  发布时间:2/13/2007 3:36:00 PM

--  
将数据库中的空格加入XML前,替换为 
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
4,939.453ms