抄自开源项目 “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>
If you mean elements with no element children (which is what your version
If all nodes that have no children at all (apart from attribute nodes), then
but this will get you terminal (leaf) text nodes too.
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.