Beispiel #1
0
        private bool StartElement()
        {
            QilNode nd;
            ReaderAnnotation ann = new ReaderAnnotation();
            string s;

            // Special case certain element names
            s = _r.LocalName;
            switch (_r.LocalName)
            {
                case "LiteralString":
                    nd = _f.LiteralString(ReadText());
                    break;

                case "LiteralInt32":
                    nd = _f.LiteralInt32(Int32.Parse(ReadText(), CultureInfo.InvariantCulture));
                    break;

                case "LiteralInt64":
                    nd = _f.LiteralInt64(Int64.Parse(ReadText(), CultureInfo.InvariantCulture));
                    break;

                case "LiteralDouble":
                    nd = _f.LiteralDouble(Double.Parse(ReadText(), CultureInfo.InvariantCulture));
                    break;

                case "LiteralDecimal":
                    nd = _f.LiteralDecimal(Decimal.Parse(ReadText(), CultureInfo.InvariantCulture));
                    break;

                case "LiteralType":
                    nd = _f.LiteralType(ParseType(ReadText()));
                    break;

                case "LiteralQName":
                    nd = ParseName(_r.GetAttribute("name"));
                    Debug.Assert(nd != null, "LiteralQName element must have a name attribute");
                    Debug.Assert(_r.IsEmptyElement, "LiteralQName element must be empty");
                    break;

                case "For":
                case "Let":
                case "Parameter":
                case "Function":
                case "RefTo":
                    ann.Id = _r.GetAttribute("id");
                    ann.Name = ParseName(_r.GetAttribute("name"));
                    goto default;

                case "XsltInvokeEarlyBound":
                    ann.ClrNamespace = _r.GetAttribute("clrNamespace");
                    goto default;

                case "ForwardDecls":
                    _inFwdDecls = true;
                    goto default;

                default:
                    // Create sequence
                    nd = _f.Sequence();
                    break;
            }

            // Save xml type and source line information
            ann.XmlType = ParseType(_r.GetAttribute("xmlType")); ;
            nd.SourceLine = ParseLineInfo(_r.GetAttribute("lineInfo"));
            nd.Annotation = ann;

            if (nd is QilList)
            {
                // Push new parent list onto stack
                _stk.Push((QilList)nd);
                return true;
            }

            // Add node to its parent's list
            _stk.Peek().Add(nd);
            return false;
        }
        private bool StartElement()
        {
            QilNode          nd;
            ReaderAnnotation ann = new ReaderAnnotation();
            string           s;

            // Special case certain element names
            s = r.LocalName;
            switch (r.LocalName)
            {
            case "LiteralString":
                nd = f.LiteralString(ReadText());
                break;

            case "LiteralInt32":
                nd = f.LiteralInt32(Int32.Parse(ReadText(), CultureInfo.InvariantCulture));
                break;

            case "LiteralInt64":
                nd = f.LiteralInt64(Int64.Parse(ReadText(), CultureInfo.InvariantCulture));
                break;

            case "LiteralDouble":
                nd = f.LiteralDouble(Double.Parse(ReadText(), CultureInfo.InvariantCulture));
                break;

            case "LiteralDecimal":
                nd = f.LiteralDecimal(Decimal.Parse(ReadText(), CultureInfo.InvariantCulture));
                break;

            case "LiteralType":
                nd = f.LiteralType(ParseType(ReadText()));
                break;

            case "LiteralQName":
                nd = ParseName(r.GetAttribute("name"));
                Debug.Assert(nd != null, "LiteralQName element must have a name attribute");
                Debug.Assert(r.IsEmptyElement, "LiteralQName element must be empty");
                break;

            case "For":
            case "Let":
            case "Parameter":
            case "Function":
            case "RefTo":
                ann.Id   = r.GetAttribute("id");
                ann.Name = ParseName(r.GetAttribute("name"));
                goto default;

            case "XsltInvokeEarlyBound":
                ann.ClrNamespace = r.GetAttribute("clrNamespace");
                goto default;

            case "ForwardDecls":
                this.inFwdDecls = true;
                goto default;

            default:
                // Create sequence
                nd = f.Sequence();
                break;
            }

            // Save xml type and source line information
            ann.XmlType   = ParseType(r.GetAttribute("xmlType"));;
            nd.SourceLine = ParseLineInfo(r.GetAttribute("lineInfo"));
            nd.Annotation = ann;

            if (nd is QilList)
            {
                // Push new parent list onto stack
                this.stk.Push((QilList)nd);
                return(true);
            }

            // Add node to its parent's list
            this.stk.Peek().Add(nd);
            return(false);
        }