public XslTemplate(Compiler c)
        {
            if (c == null)
            {
                return;        // built in template
            }
            this.style = c.CurrentStylesheet;

            c.PushScope();

            if (c.Input.Name == "template" &&
                c.Input.NamespaceURI == Compiler.XsltNamespace &&
                c.Input.MoveToAttribute("mode", String.Empty))
            {
                c.Input.MoveToParent();
                if (!c.Input.MoveToAttribute("match", String.Empty))
                {
                    throw new XsltCompileException("XSLT 'template' element must not have 'mode' attribute when it does not have 'match' attribute", null, c.Input);
                }
                c.Input.MoveToParent();
            }

            if (c.Input.NamespaceURI != Compiler.XsltNamespace)
            {
                this.name  = QName.Empty;
                this.match = c.CompilePattern("/", c.Input);
                this.mode  = QName.Empty;
            }
            else
            {
                this.name  = c.ParseQNameAttribute("name");
                this.match = c.CompilePattern(c.GetAttribute("match"), c.Input);
                this.mode  = c.ParseQNameAttribute("mode");

                string pri = c.GetAttribute("priority");
                if (pri != null)
                {
                    try
                    {
                        this.priority = double.Parse(pri, CultureInfo.InvariantCulture);
                    }
                    catch (FormatException ex)
                    {
                        throw new XsltException("Invalid priority number format", ex, c.Input);
                    }
                }
            }
            Parse(c);

            stackSize = c.PopScope().VariableHighTide;
        }
 public XslTemplate(Compiler c)
 {
     if (c == null)
     {
         return;
     }
     this.style = c.CurrentStylesheet;
     c.PushScope();
     if (c.Input.Name == "template" && c.Input.NamespaceURI == "http://www.w3.org/1999/XSL/Transform" && c.Input.MoveToAttribute("mode", string.Empty))
     {
         c.Input.MoveToParent();
         if (!c.Input.MoveToAttribute("match", string.Empty))
         {
             throw new XsltCompileException("XSLT 'template' element must not have 'mode' attribute when it does not have 'match' attribute", null, c.Input);
         }
         c.Input.MoveToParent();
     }
     if (c.Input.NamespaceURI != "http://www.w3.org/1999/XSL/Transform")
     {
         this.name  = XmlQualifiedName.Empty;
         this.match = c.CompilePattern("/", c.Input);
         this.mode  = XmlQualifiedName.Empty;
     }
     else
     {
         this.name  = c.ParseQNameAttribute("name");
         this.match = c.CompilePattern(c.GetAttribute("match"), c.Input);
         this.mode  = c.ParseQNameAttribute("mode");
         string attribute = c.GetAttribute("priority");
         if (attribute != null)
         {
             try
             {
                 this.priority = double.Parse(attribute, CultureInfo.InvariantCulture);
             }
             catch (FormatException innerException)
             {
                 throw new XsltException("Invalid priority number format", innerException, c.Input);
             }
         }
     }
     this.Parse(c);
     this.stackSize = c.PopScope().VariableHighTide;
 }
示例#3
0
        public XslKey(Compiler c)
        {
            this.name            = c.ParseQNameAttribute("name");
            c.KeyCompilationMode = true;
            this.useExpr         = c.CompileExpression(c.GetAttribute("use"));
            if (this.useExpr == null)
            {
                this.useExpr = c.CompileExpression(".");
            }
            c.AssertAttribute("match");
            string attribute = c.GetAttribute("match");

            this.matchPattern    = c.CompilePattern(attribute, c.Input);
            c.KeyCompilationMode = false;
        }
示例#4
0
		public XslKey (Compiler c)
		{
			this.name = c.ParseQNameAttribute ("name");

			c.KeyCompilationMode = true;
			useExpr = c.CompileExpression (c.GetAttribute ("use"));
			if (useExpr == null)
				useExpr = c.CompileExpression (".");

			c.AssertAttribute ("match");
			string matchString = c.GetAttribute ("match");
			this.matchPattern = c.CompilePattern (matchString, c.Input);
			c.KeyCompilationMode = false;
		}
示例#5
0
		public XslTemplate (Compiler c)
		{
			if (c == null) return; // built in template
			this.style = c.CurrentStylesheet;
			
			c.PushScope ();

			if (c.Input.Name == "template" &&
			    c.Input.NamespaceURI == Compiler.XsltNamespace &&
			    c.Input.MoveToAttribute ("mode", String.Empty)) {
				c.Input.MoveToParent ();
				if (!c.Input.MoveToAttribute ("match", String.Empty))
					throw new XsltCompileException ("XSLT 'template' element must not have 'mode' attribute when it does not have 'match' attribute", null, c.Input);
				c.Input.MoveToParent ();
			}

			if (c.Input.NamespaceURI != Compiler.XsltNamespace) {
				this.name = QName.Empty;
				this.match = c.CompilePattern ("/", c.Input);
				this.mode = QName.Empty;
			} else {
				this.name = c.ParseQNameAttribute ("name");
				this.match = c.CompilePattern (c.GetAttribute ("match"), c.Input);
				this.mode = c.ParseQNameAttribute ("mode");
				
				string pri = c.GetAttribute ("priority");
				if (pri != null) {
					try {
						this.priority = double.Parse (pri, CultureInfo.InvariantCulture);
					} catch (FormatException ex) {
						throw new XsltException ("Invalid priority number format", ex, c.Input);
					}
				}
			}
			Parse (c);
			
			stackSize = c.PopScope ().VariableHighTide;
			
		}