六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 128|回复: 0

通过XSLT处理所有的叶结点

[复制链接]

升级  61%

251

主题

251

主题

251

主题

进士

Rank: 4

积分
805
 楼主| 发表于 2013-2-7 19:33:16 | 显示全部楼层 |阅读模式
抄自开源项目  “Dynamic Soap Portlet”




<xsl:for-each select="./*"><xsl:choose><xsl:when test="count(./*) = 0 and count(./@*) = 0"><dd style="display: list-item"><xsl:value-of select="." /></dd></xsl:when><xsl:otherwise>...</xsl:otherwise></xsl:choose></xsl:for-each>


另外还有人说, http://www.biglist.com/lists/xsl-list/archives/200010/msg00086.html

If you mean elements with no element children (which is what your version
is), then
//*[not(*)]

If all nodes that have no children at all (apart from attribute nodes), then
//node[not(node())]

but this will get you terminal (leaf) text nodes too.

//*[not(node())]
gets you all elements that have no text nodes, elements, comments or
processing instructions inside them.

They all have in common the feature that an empty node-set evaluates, in an
expression that requires a boolean operand (such as a predicate []), as a
boolean false; so when you do the not() operation on an empty node-set, you
get boolean true.
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表