Exemple #1
0
        internal static void CheckXsltValue(IList <XPathItem> val)
        {
            // IsDocOrderDistinct is not always set to true even if the node-set is ordered
            // Debug.Assert(val.Count <= 1 || val.IsDocOrderDistinct, "All node-sets must be ordered");

            if (val.Count == 1)
            {
                XsltFunctions.EXslObjectType(val);
            }
            else
            {
                // Every item must be a node, but for performance reasons we check only
                // the first two and the last two items
                int count = val.Count;
                for (int idx = 0; idx < count; idx++)
                {
                    if (!val[idx].IsNode)
                    {
                        Debug.Fail("Invalid XSLT value");
                        break;
                    }
                    if (idx == 1)
                    {
                        idx += Math.Max(count - 4, 0);
                    }
                }
            }
        }
        private void FormatItem(StringBuilder sb, XPathItem item, char startChar, int length)
        {
            double dblVal;

            if (item.ValueType == typeof(int))
            {
                dblVal = (double)item.ValueAsInt;
            }
            else
            {
                Debug.Assert(item.ValueType == typeof(double), "Item must be either of type int, or double");
                dblVal = XsltFunctions.Round(item.ValueAsDouble);
            }

            Debug.Assert(1 <= dblVal && dblVal < double.PositiveInfinity);
            char zero = '0';

            switch (startChar)
            {
            case '1':
                break;

            case 'A':
            case 'a':
                if (dblVal <= MaxAlphabeticValue)
                {
                    ConvertToAlphabetic(sb, dblVal, startChar, 26);
                    return;
                }
                break;

            case 'I':
            case 'i':
                if (dblVal <= MaxRomanValue)
                {
                    ConvertToRoman(sb, dblVal, /*upperCase:*/ startChar == 'I');
                    return;
                }
                break;

            default:
                Debug.Assert(CharUtil.IsDecimalDigitOne(startChar), "Unexpected startChar: " + startChar);
                zero = (char)(startChar - 1);
                break;
            }

            sb.Append(ConvertToDecimal(dblVal, length, zero, _groupingSeparator, _groupingSize));
        }