Using
//Order/node()[not(self::text()[not(normalize-space())])]
this selects all child nodes of any Order element, except those that are text nodes consisting entirely of white space.
XSLT Based Validation :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="/*"> <xsl:variable name="vSel1" select="//Order/node()"/> <xsl:variable name="vSel2" select= "//Order/node()[not(self::text()[not(normalize-space())])]"/> <xsl:for-each select="$vSel1"> <xsl:value-of select="concat('
',position(), ': ')"/> <xsl:copy-of select="."/> <xsl:text>
</xsl:text> </xsl:for-each> ================ <xsl:for-each select="$vSel2"> <xsl:value-of select="concat('
',position(), ': ')"/> <xsl:copy-of select="."/> <xsl:text>
</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>
when this conversion is applied to the following XML document :
<t> <Order> <a/> <b>xxx</b> <c/> </Order> <Order> <d/> <e>xxx</e> <f/> </Order> </t>
two XPath expressions are calculated and nodes are derived from two corresponding sets of selected nodes, each of which is preceded by its position number :
1: 2: <a/> 3: 4: <b>xxx</b> 5: 6: <c/> 7: 8: 9: <d/> 10: 11: <e>xxx</e> 12: 13: <f/> 14: ================ 1: <a/> 2: <b>xxx</b> 3: <c/> 4: <d/> 5: <e>xxx</e> 6: <f/>
source share