title: Count number of character in a variable in XSLT 2.0
body: <p>I have an XML which is describe below. This xml contains for example address node(<strong>address1</strong>). I just want to count the number of occurrence of character(<strong>,</strong>) in the address text. I am using template so just to mention I an storing address text into xslt variable.</p>
  
  <p>Sample XML:</p>
  
  <pre><code>&lt;xml&gt;
      &lt;address1&gt;123 Fake Street, Alberta, Alberta, 234567&lt;/address1&gt; 
      &lt;address1&gt;123 Fake Street, Alberta, Alberta&lt;/address1&gt;
  &lt;/xml&gt; 
  </code></pre>
  
  <p>My XSLT:</p>
  
  <pre><code>&lt;xsl:variable name="address" select="//*[local-name()='address1')]"/&gt;
  &lt;xsl:variable name="totalComma" select="count(contains($address, ','))"/&gt;
  &lt;xsl:choose&gt;
  &lt;xsl:when test="$totalComma = 3"&gt;
      &lt;!--Do something--&gt;
  &lt;/xsl:when&gt;
  &lt;xsl:when test="$totalComma = 2"&gt;
      &lt;!--Do something--&gt;
  &lt;/xsl:when&gt;
  &lt;/xsl:choose&gt;
  </code></pre>
  
  <p>I don't know whether this is correct solution or not but didn't get expected result. A little help would be highly appreciable. </p>