code: String getCountString(TransformerImpl transformer, int sourceNode)
            throws TransformerException
    {
  
      long[] list = null;
      XPathContext xctxt = transformer.getXPathContext();
      CountersTable ctable = transformer.getCountersTable();
  
      if (null != m_valueExpr)
      {
        XObject countObj = m_valueExpr.execute(xctxt, sourceNode, this);
        //According to Errata E24
        double d_count = java.lang.Math.floor(countObj.num()+ 0.5);
        if (Double.isNaN(d_count)) return "NaN";
        else if (d_count < 0 && Double.isInfinite(d_count)) return "-Infinity";
        else if (Double.isInfinite(d_count)) return "Infinity";
        else if (d_count == 0) return "0";
        else{
                long count = (long)d_count;
                list = new long[1];
                list[0] = count;              
        }
      }
      else
      {
        if (Constants.NUMBERLEVEL_ANY == m_level)
        {
          list = new long[1];
          list[0] = ctable.countNode(xctxt, this, sourceNode);
        }
        else
        {
          NodeVector ancestors =
            getMatchingAncestors(xctxt, sourceNode,
                                 Constants.NUMBERLEVEL_SINGLE == m_level);
          int lastIndex = ancestors.size() - 1;
  
          if (lastIndex >= 0)
          {
            list = new long[lastIndex + 1];
  
            for (int i = lastIndex; i >= 0; i--)
            {
              int target = ancestors.elementAt(i);
  
              list[lastIndex - i] = ctable.countNode(xctxt, this, target);
            }
          }
        }
      }
  
      return (null != list)
             ? formatNumberList(transformer, list, sourceNode) : "";
    }
docs: Given an XML source node, get the count according to the
  parameters set up by the xsl:number attributes.
  @param transformer non-null reference to the the current transform-time state.
  @param sourceNode The source node being counted.
  
  @return The count of nodes
  
  @throws TransformerException