Пример #1
0
        private void HandleTopLevelElement(Compiler c)
        {
            XPathNavigator n = c.Input;

            switch (n.NamespaceURI)
            {
            case XsltNamespace:
                switch (n.LocalName)
                {
                case "include":
                    HandleInclude(c);
                    break;

                case "preserve-space":
                    AddSpaceControls(c.ParseQNameListAttribute("elements"), XmlSpace.Preserve, n);
                    break;

                case "strip-space":
                    AddSpaceControls(c.ParseQNameListAttribute("elements"), XmlSpace.Default, n);
                    break;

                case "namespace-alias":
                    // do nothing. It is handled in prior.
                    break;

                case "attribute-set":
                    c.AddAttributeSet(new XslAttributeSet(c));
                    break;

                case "key":
                    XslKey key = new XslKey(c);
                    if (keys [key.Name] == null)
                    {
                        keys [key.Name] = new ArrayList();
                    }
                    ((ArrayList)keys [key.Name]).Add(key);
                    break;

                case "output":
                    c.CompileOutput();
                    break;

                case "decimal-format":
                    c.CompileDecimalFormat();
                    break;

                case "template":
                    templates.Add(new XslTemplate(c));
                    break;

                case "variable":
                    XslGlobalVariable gvar = new XslGlobalVariable(c);
                    variables [gvar.Name] = gvar;
                    break;

                case "param":
                    XslGlobalParam gpar = new XslGlobalParam(c);
                    variables [gpar.Name] = gpar;
                    break;

                default:
                    if (version == "1.0")
                    {
                        throw new XsltCompileException("Unrecognized top level element after imports", null, c.Input);
                    }
                    break;
                }
                break;

            case MSXsltNamespace:
                switch (n.LocalName)
                {
                case "script":
                    c.ScriptManager.AddScript(c);
                    break;
                }
                break;
            }
        }
Пример #2
0
        private void HandleTopLevelElement(Compiler c)
        {
            XPathNavigator input        = c.Input;
            string         namespaceURI = input.NamespaceURI;

            if (namespaceURI != null)
            {
                if (XslStylesheet.< > f__switch$map26 == null)
                {
                    XslStylesheet.< > f__switch$map26 = new Dictionary <string, int>(2)
                    {
                        {
                            "http://www.w3.org/1999/XSL/Transform",
                            0
                        },
                        {
                            "urn:schemas-microsoft-com:xslt",
                            1
                        }
                    };
                }
                int num;
                if (XslStylesheet.< > f__switch$map26.TryGetValue(namespaceURI, out num))
                {
                    if (num != 0)
                    {
                        if (num == 1)
                        {
                            string localName = input.LocalName;
                            if (localName != null)
                            {
                                if (XslStylesheet.< > f__switch$map25 == null)
                                {
                                    XslStylesheet.< > f__switch$map25 = new Dictionary <string, int>(1)
                                    {
                                        {
                                            "script",
                                            0
                                        }
                                    };
                                }
                                int num2;
                                if (XslStylesheet.< > f__switch$map25.TryGetValue(localName, out num2))
                                {
                                    if (num2 == 0)
                                    {
                                        c.ScriptManager.AddScript(c);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        string localName = input.LocalName;
                        switch (localName)
                        {
                        case "include":
                            this.HandleInclude(c);
                            goto IL_2B0;

                        case "preserve-space":
                            this.AddSpaceControls(c.ParseQNameListAttribute("elements"), XmlSpace.Preserve, input);
                            goto IL_2B0;

                        case "strip-space":
                            this.AddSpaceControls(c.ParseQNameListAttribute("elements"), XmlSpace.Default, input);
                            goto IL_2B0;

                        case "namespace-alias":
                            goto IL_2B0;

                        case "attribute-set":
                            c.AddAttributeSet(new XslAttributeSet(c));
                            goto IL_2B0;

                        case "key":
                        {
                            XslKey xslKey = new XslKey(c);
                            if (this.keys[xslKey.Name] == null)
                            {
                                this.keys[xslKey.Name] = new ArrayList();
                            }
                            ((ArrayList)this.keys[xslKey.Name]).Add(xslKey);
                            goto IL_2B0;
                        }

                        case "output":
                            c.CompileOutput();
                            goto IL_2B0;

                        case "decimal-format":
                            c.CompileDecimalFormat();
                            goto IL_2B0;

                        case "template":
                            this.templates.Add(new XslTemplate(c));
                            goto IL_2B0;

                        case "variable":
                        {
                            XslGlobalVariable xslGlobalVariable = new XslGlobalVariable(c);
                            this.variables[xslGlobalVariable.Name] = xslGlobalVariable;
                            goto IL_2B0;
                        }

                        case "param":
                        {
                            XslGlobalParam xslGlobalParam = new XslGlobalParam(c);
                            this.variables[xslGlobalParam.Name] = xslGlobalParam;
                            goto IL_2B0;
                        }
                        }
                        if (this.version == "1.0")
                        {
                            throw new XsltCompileException("Unrecognized top level element after imports", null, c.Input);
                        }
                        IL_2B0 :;
                    }
                }
            }
        }