请问如何限制XML的输出,当字符大于一定数量时,显示省略号!

我是个XML菜鸟!现在公司用了发布系统输出文章标题和时间,现在需要的是在标题过长时,用省略号显示。另外必须要在单元格中实现,因为单元格中有用到样式表!应该不是个很难的问题吧,希望大家回答,能用了就给分!
---------------------------------------------------------------

if you are using XSLT, you can use string-length and substring functions, for example

1<xsl:template match="title">
2<xsl:choose>
3<xsl:when test="string-length(.) &gt; 10">
4<xsl:value-of select="substring(.,1,10)"></xsl:value-of><xsl:text>.....</xsl:text>
5</xsl:when>
6<xsl:otherwise><xsl:value-of select="."></xsl:value-of></xsl:otherwise>
7</xsl:choose>
8</xsl:template>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus