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);
}
}
}
}