Re: [xsl] Find node with no child text() nodes

Subject: Re: [xsl] Find node with no child text() nodes
From: Piet van Oostrum <piet@xxxxxxxxxxxxxx>
Date: Thu, 5 May 2011 09:43:40 +0200
Karl Stubsjoen wrote:

 > Need help with XSLT 1.0 template please.  How do you match on block_x
 > when no descendant text() nodes exist?  Note:  there is no predictive
 > knowledge of the depth of block within block_x.  In sample below,
 > block_x id 2 should match.  Like:
 > <blocks>
 >   <block_x id="1">
 >     <block/>
 >     <block/>
 >     <block>asdf</block>
 >   </block_x>
 >   <block_x id="2">
 >     <block/>
 >     <block>
 >        <sub_block/>
 >     </block>
 > </block_x>
 > </blocks>

Your description is not very clear. do you just want a block_x with id=2? Or
does the fact that is has no descendent text() play a role in the selection?

If only id=2 is important it would be:

<xsl:template match="//block_x[id='2']">

Piet van Oostrum
Utrecht, NL. URL:

Current Thread