title: xslt count sibling
body: <p>I have a sample":</p>
  
  <pre><code>&lt;Root&gt;
      &lt;A rename="yes,it is option 1"/&gt;
      &lt;C rename="no"/&gt;
      &lt;A rename="yes,it is option 2"/&gt;
      &lt;C rename="no"/&gt;
      &lt;C rename="yes"/&gt;
      &lt;C rename="no"/&gt;  
      &lt;A rename="yes,it is option 3"/&gt;
      &lt;A rename="yes,it is option 4"/&gt;
      &lt;C rename="no"/&gt;
      &lt;C rename="yes"/&gt;
      &lt;C rename="no"/&gt;      
      &lt;C rename="no"/&gt;        
  &lt;/Root&gt;
  </code></pre>
  
  <p>Then I apply a template look like this:</p>
  
  <pre><code>   &lt;xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
   &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt;
   &lt;xsl:template match="A"&gt;
              &lt;p&gt;&lt;b&gt;option1: &lt;xsl:value-of select="count(following-sibling::C[preceding-sibling::A[1]/@rename[contains(.,'option 1')]])"/&gt;&lt;/b&gt;&lt;/p&gt;
              &lt;p&gt;&lt;b&gt;option2: &lt;xsl:value-of select="count(following-sibling::C[preceding-sibling::A[1]/@rename[contains(.,'option 2')]])"/&gt;&lt;/b&gt;&lt;/p&gt;            
              &lt;p&gt;&lt;b&gt;option3: &lt;xsl:value-of select="count(following-sibling::C[preceding-sibling::A[1]/@rename[contains(.,'option 3')]])"/&gt;&lt;/b&gt;&lt;/p&gt;
              &lt;p&gt;&lt;b&gt;option4: &lt;xsl:value-of select="count(following-sibling::C[preceding-sibling::A[1]/@rename[contains(.,'option 4')]])"/&gt;&lt;/b&gt;&lt;/p&gt;                        
   &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>but i want the output look like this,if there are not sibling following A, we just ignore this one.just print these @rename contains "option" and also contains  elements</p>
  
  <pre><code>option1: 1 
  
  option2: 3 
  
  option4: 4 
  </code></pre>
  
  <p>What I get now is:</p>
  
  <pre><code>option1: 1 
  
  option2: 3 
  
  option3: 0 
  
  option4: 4 
  
  option1: 0 
  
  option2: 3 
  
  option3: 0 
  
  option4: 4 
  
  option1: 0 
  
  option2: 0 
  
  option3: 0 
  
  option4: 4 
  
  option1: 0 
  
  option2: 0 
  
  option3: 0 
  
  option4: 4 
  </code></pre>