通过XSLT处理所有的叶结点

抄自开源项目  “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.

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.