Q:

How to count elements which have both children?

I have xml like this;
 <A Ref=""blah"" Completed=""Y"" ErrorCount=""0"">
      <B Type=""Output"">
           <C>
                <D Val=""02"" />
                <E Val=""05"" />
           </C>  
           <C>
                <D Val=""02"" />
                <F Val=""05"" />
           </C>             
      </B >
 </A>

I want to count the number of 'C' elements that have both a D and E child.  So in this case it would be 1 (as the second C has a D & F)
I can get the count using
<xsl:value-of select="count(B/C/child::D"/>

but I can't see how to specify that C should have child E as well.
I tried 
<xsl:value-of select="count(B/C/child::D and B/C/child::E"/>

but it doesn't like it

A:

Use a predicate:
<xsl:value-of select="count(B/C[D and E])"/>

The square bracket expression puts constraints on the set of nodes selected, so what this is saying is find all the B element children of the current node, then for each of those find their C element children but filter that list to include only those that themselves have at least one D and one E child.

