Ejemplo n.º 1
0
        protected override void Compile(Compiler c)
        {
            if (c.Debugger != null)
            {
                c.Debugger.DebugCompile(c.Input);
            }

            c.CheckExtraAttributes("element", "name", "namespace", "use-attribute-sets");

            name     = c.ParseAvtAttribute("name");
            ns       = c.ParseAvtAttribute("namespace");
            nsDecls  = c.GetNamespacesToCopy();
            calcName = XslAvt.AttemptPreCalc(ref name);

            if (calcName != null)
            {
                int colonAt = calcName.IndexOf(':');
                if (colonAt == 0)
                {
                    throw new XsltCompileException("Invalid name attribute", null, c.Input);
                }
                calcPrefix = colonAt < 0 ? String.Empty : calcName.Substring(0, colonAt);
                if (colonAt > 0)
                {
                    calcName = calcName.Substring(colonAt + 1);
                }

                try {
                    XmlConvert.VerifyNCName(calcName);
                    if (calcPrefix != String.Empty)
                    {
                        XmlConvert.VerifyNCName(calcPrefix);
                    }
                } catch (XmlException ex) {
                    throw new XsltCompileException("Invalid name attribute", ex, c.Input);
                }

                if (ns == null)
                {
                    calcNs = c.Input.GetNamespace(calcPrefix);
                    if (calcPrefix != String.Empty && calcNs == String.Empty)
                    {
                        throw new XsltCompileException("Invalid name attribute", null, c.Input);
                    }
                }
            }
            else if (ns != null)
            {
                calcNs = XslAvt.AttemptPreCalc(ref ns);
            }

            useAttributeSets = c.ParseQNameListAttribute("use-attribute-sets");

            isEmptyElement = c.Input.IsEmptyElement;

            if (c.Input.MoveToFirstChild())
            {
                value = c.CompileTemplateContent(XPathNodeType.Element);
                c.Input.MoveToParent();
            }
        }
Ejemplo n.º 2
0
 protected override void Compile(Compiler c)
 {
     if (c.Debugger != null)
     {
         c.Debugger.DebugCompile(c.Input);
     }
     c.CheckExtraAttributes("element", new string[]
     {
         "name",
         "namespace",
         "use-attribute-sets"
     });
     this.name     = c.ParseAvtAttribute("name");
     this.ns       = c.ParseAvtAttribute("namespace");
     this.nsDecls  = c.GetNamespacesToCopy();
     this.calcName = XslAvt.AttemptPreCalc(ref this.name);
     if (this.calcName != null)
     {
         int num = this.calcName.IndexOf(':');
         if (num == 0)
         {
             throw new XsltCompileException("Invalid name attribute", null, c.Input);
         }
         this.calcPrefix = ((num >= 0) ? this.calcName.Substring(0, num) : string.Empty);
         if (num > 0)
         {
             this.calcName = this.calcName.Substring(num + 1);
         }
         try
         {
             XmlConvert.VerifyNCName(this.calcName);
             if (this.calcPrefix != string.Empty)
             {
                 XmlConvert.VerifyNCName(this.calcPrefix);
             }
         }
         catch (XmlException innerException)
         {
             throw new XsltCompileException("Invalid name attribute", innerException, c.Input);
         }
         if (this.ns == null)
         {
             this.calcNs = c.Input.GetNamespace(this.calcPrefix);
             if (this.calcPrefix != string.Empty && this.calcNs == string.Empty)
             {
                 throw new XsltCompileException("Invalid name attribute", null, c.Input);
             }
         }
     }
     else if (this.ns != null)
     {
         this.calcNs = XslAvt.AttemptPreCalc(ref this.ns);
     }
     this.useAttributeSets = c.ParseQNameListAttribute("use-attribute-sets");
     this.isEmptyElement   = c.Input.IsEmptyElement;
     if (c.Input.MoveToFirstChild())
     {
         this.value = c.CompileTemplateContent(XPathNodeType.Element);
         c.Input.MoveToParent();
     }
 }
        protected override void Compile(Compiler c)
        {
            if (c.Debugger != null)
            {
                c.Debugger.DebugCompile(c.Input);
            }

            XPathNavigator nav = c.Input.Clone();

            nsDecls = c.GetNamespacesToCopy();

            c.CheckExtraAttributes("attribute", "name", "namespace");

            name = c.ParseAvtAttribute("name");
            if (name == null)
            {
                throw new XsltCompileException("Attribute \"name\" is required on XSLT attribute element", null, c.Input);
            }
            ns = c.ParseAvtAttribute("namespace");

            calcName   = XslAvt.AttemptPreCalc(ref name);
            calcPrefix = String.Empty;

            if (calcName != null)
            {
                int colonAt = calcName.IndexOf(':');
                calcPrefix = colonAt < 0 ? String.Empty : calcName.Substring(0, colonAt);
                calcName   = colonAt < 0 ? calcName : calcName.Substring(colonAt + 1, calcName.Length - colonAt - 1);

                try
                {
                    XmlConvert.VerifyNCName(calcName);
                    if (calcPrefix != String.Empty)
                    {
                        XmlConvert.VerifyNCName(calcPrefix);
                    }
                }
                catch (XmlException ex)
                {
                    throw new XsltCompileException("Invalid attribute name", ex, c.Input);
                }
            }

            if (calcPrefix != String.Empty)
            {
                calcPrefix = c.CurrentStylesheet.GetActualPrefix(calcPrefix);
                if (calcPrefix == null)
                {
                    calcPrefix = String.Empty;
                }
            }

            if (calcPrefix != String.Empty && ns == null)
            {
                calcNs = nav.GetNamespace(calcPrefix);
            }
            else if (ns != null)
            {
                calcNs = XslAvt.AttemptPreCalc(ref ns);
            }

            if (c.Input.MoveToFirstChild())
            {
                value = c.CompileTemplateContent(XPathNodeType.Attribute);
                c.Input.MoveToParent();
            }
        }
Ejemplo n.º 4
0
        protected override void Compile(Compiler c)
        {
            if (c.Debugger != null)
            {
                c.Debugger.DebugCompile(c.Input);
            }
            XPathNavigator xpathNavigator = c.Input.Clone();

            this.nsDecls = c.GetNamespacesToCopy();
            c.CheckExtraAttributes("attribute", new string[]
            {
                "name",
                "namespace"
            });
            this.name = c.ParseAvtAttribute("name");
            if (this.name == null)
            {
                throw new XsltCompileException("Attribute \"name\" is required on XSLT attribute element", null, c.Input);
            }
            this.ns         = c.ParseAvtAttribute("namespace");
            this.calcName   = XslAvt.AttemptPreCalc(ref this.name);
            this.calcPrefix = string.Empty;
            if (this.calcName != null)
            {
                int num = this.calcName.IndexOf(':');
                this.calcPrefix = ((num >= 0) ? this.calcName.Substring(0, num) : string.Empty);
                this.calcName   = ((num >= 0) ? this.calcName.Substring(num + 1, this.calcName.Length - num - 1) : this.calcName);
                try
                {
                    XmlConvert.VerifyNCName(this.calcName);
                    if (this.calcPrefix != string.Empty)
                    {
                        XmlConvert.VerifyNCName(this.calcPrefix);
                    }
                }
                catch (XmlException innerException)
                {
                    throw new XsltCompileException("Invalid attribute name", innerException, c.Input);
                }
            }
            if (this.calcPrefix != string.Empty)
            {
                this.calcPrefix = c.CurrentStylesheet.GetActualPrefix(this.calcPrefix);
                if (this.calcPrefix == null)
                {
                    this.calcPrefix = string.Empty;
                }
            }
            if (this.calcPrefix != string.Empty && this.ns == null)
            {
                this.calcNs = xpathNavigator.GetNamespace(this.calcPrefix);
            }
            else if (this.ns != null)
            {
                this.calcNs = XslAvt.AttemptPreCalc(ref this.ns);
            }
            if (c.Input.MoveToFirstChild())
            {
                this.value = c.CompileTemplateContent(XPathNodeType.Attribute);
                c.Input.MoveToParent();
            }
        }