private QilNode CompileGroupingSizeAttribute(string attValue, bool fwdCompat)
{
QilNode result = CompileStringAvt(attValue);
if (result == null)
{
return _f.Double(0);
}
else if (result.NodeType == QilNodeType.LiteralString)
{
string groupingSize = (string)(QilLiteral)result;
// NOTE: It is unclear from the spec what we should do with float numbers here.
// Let's apply XPath number and round functions as usual, suppressing any conversion errors.
double dblGroupingSize = XsltFunctions.Round(XPathConvert.StringToDouble(groupingSize));
if (0 <= dblGroupingSize && dblGroupingSize <= int.MaxValue)
{
return _f.Double(dblGroupingSize);
}
// NaN goes here as well
return _f.Double(0);
}
else
{
// NOTE: We should have the same checks for both compile time and execution time
QilIterator i = _f.Let(_f.ConvertToNumber(result));
return _f.Loop(i,
_f.Conditional(_f.And(_f.Lt(_f.Double(0), i), _f.Lt(i, _f.Double(int.MaxValue))),
i,
_f.Double(0)
)
);
}
}