Exemplo n.º 1
0
 public XslLiteralAttribute(Compiler c)
 {
     this.prefix = c.Input.Prefix;
     if (prefix.Length > 0)
     {
         string alias =
             c.CurrentStylesheet.GetActualPrefix(prefix);
         if (alias != prefix)
         {
             prefix = alias;
             XPathNavigator clone = c.Input.Clone();
             clone.MoveToParent();
             nsUri = clone.GetNamespace(alias);
         }
         else
         {
             nsUri = c.Input.NamespaceURI;
         }
     }
     else
     {
         nsUri = String.Empty;
     }
     this.localname = c.Input.LocalName;
     this.val       = new XslAvt(c.Input.Value, c);
 }
 public XslLiteralAttribute(Compiler c)
 {
     this.prefix = c.Input.Prefix;
     if (this.prefix.Length > 0)
     {
         string actualPrefix = c.CurrentStylesheet.GetActualPrefix(this.prefix);
         if (actualPrefix != this.prefix)
         {
             this.prefix = actualPrefix;
             XPathNavigator xpathNavigator = c.Input.Clone();
             xpathNavigator.MoveToParent();
             this.nsUri = xpathNavigator.GetNamespace(actualPrefix);
         }
         else
         {
             this.nsUri = c.Input.NamespaceURI;
         }
     }
     else
     {
         this.nsUri = string.Empty;
     }
     this.localname = c.Input.LocalName;
     this.val       = new XslAvt(c.Input.Value, c);
 }
Exemplo n.º 3
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			c.CheckExtraAttributes ("processing-instruction", "name");

			name = c.ParseAvtAttribute ("name");

			if (!c.Input.MoveToFirstChild ()) return;
			
			value = c.CompileTemplateContent (XPathNodeType.ProcessingInstruction);
			c.Input.MoveToParent ();
		}
Exemplo n.º 4
0
 public static string AttemptPreCalc(ref XslAvt avt)
 {
     if (avt == null)
     {
         return(null);
     }
     if (avt.simpleString != null)
     {
         string result = avt.simpleString;
         avt = null;
         return(result);
     }
     return(null);
 }
Exemplo n.º 5
0
		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 ();
			}
		}
Exemplo n.º 6
0
        protected override void Compile(Compiler c)
        {
            if (c.Debugger != null)
            {
                c.Debugger.DebugCompile(base.DebugInput);
            }
            c.CheckExtraAttributes("number", new string[]
            {
                "level",
                "count",
                "from",
                "value",
                "format",
                "lang",
                "letter-value",
                "grouping-separator",
                "grouping-size"
            });
            string attribute = c.GetAttribute("level");

            switch (attribute)
            {
            case "single":
                this.level = XslNumberingLevel.Single;
                goto IL_12C;

            case "multiple":
                this.level = XslNumberingLevel.Multiple;
                goto IL_12C;

            case "any":
                this.level = XslNumberingLevel.Any;
                goto IL_12C;
            }
            this.level = XslNumberingLevel.Single;
IL_12C:
            this.count             = c.CompilePattern(c.GetAttribute("count"), c.Input);
            this.from              = c.CompilePattern(c.GetAttribute("from"), c.Input);
            this.value             = c.CompileExpression(c.GetAttribute("value"));
            this.format            = c.ParseAvtAttribute("format");
            this.lang              = c.ParseAvtAttribute("lang");
            this.letterValue       = c.ParseAvtAttribute("letter-value");
            this.groupingSeparator = c.ParseAvtAttribute("grouping-separator");
            this.groupingSize      = c.ParseAvtAttribute("grouping-size");
        }
Exemplo n.º 7
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 ();
			}
		}
Exemplo n.º 8
0
 protected override void Compile(Compiler c)
 {
     if (c.Debugger != null)
     {
         c.Debugger.DebugCompile(base.DebugInput);
     }
     c.CheckExtraAttributes("processing-instruction", new string[]
     {
         "name"
     });
     this.name = c.ParseAvtAttribute("name");
     if (!c.Input.MoveToFirstChild())
     {
         return;
     }
     this.value = c.CompileTemplateContent(XPathNodeType.ProcessingInstruction);
     c.Input.MoveToParent();
 }
Exemplo n.º 9
0
			public XslLiteralAttribute (Compiler c)
			{
				this.prefix = c.Input.Prefix;
				if (prefix.Length > 0) {
					string alias = 
						c.CurrentStylesheet.GetActualPrefix (prefix);
					if (alias != prefix) {
						prefix = alias;
						XPathNavigator clone = c.Input.Clone ();
						clone.MoveToParent ();
						nsUri = clone.GetNamespace (alias);
					}
					else
						nsUri = c.Input.NamespaceURI;
				}
				else
					nsUri = String.Empty;
				this.localname = c.Input.LocalName;
				this.val = new XslAvt (c.Input.Value, c);
			}
        XslNumberFormatter GetNumberFormatter(XslTransformProcessor p)
        {
            string  formatStr             = "1";
            string  lang                  = null;
            string  letterValue           = null;
            char    groupingSeparatorChar = '\0';
            decimal groupingSize          = 0;

            if (this.format != null)
            {
                formatStr = this.format.Evaluate(p);
            }

            if (this.lang != null)
            {
                lang = this.lang.Evaluate(p);
            }

            if (this.letterValue != null)
            {
                letterValue = this.letterValue.Evaluate(p);
            }

            if (groupingSeparator != null)
            {
                groupingSeparatorChar = this.groupingSeparator.Evaluate(p) [0];
            }

            if (this.groupingSize != null)
            {
                groupingSize = decimal.Parse(this.groupingSize.Evaluate(p), CultureInfo.InvariantCulture);
            }

            //FIXME: Negative test compliency: .NET throws exception on negative grouping-size
            if (groupingSize > Int32.MaxValue || groupingSize < 1)
            {
                groupingSize = 0;
            }

            return(new XslNumberFormatter(formatStr, lang, letterValue, groupingSeparatorChar, (int)groupingSize));
        }
        protected override void Compile(Compiler c)
        {
            if (c.Debugger != null)
            {
                c.Debugger.DebugCompile(this.DebugInput);
            }

            c.CheckExtraAttributes("number", "level", "count", "from", "value", "format", "lang", "letter-value", "grouping-separator", "grouping-size");

            switch (c.GetAttribute("level"))
            {
            case "single":
                level = XslNumberingLevel.Single;
                break;

            case "multiple":
                level = XslNumberingLevel.Multiple;
                break;

            case "any":
                level = XslNumberingLevel.Any;
                break;

            case null:
            case "":
            default:
                level = XslNumberingLevel.Single; // single == default
                break;
            }

            count = c.CompilePattern(c.GetAttribute("count"), c.Input);
            from  = c.CompilePattern(c.GetAttribute("from"), c.Input);
            value = c.CompileExpression(c.GetAttribute("value"));

            format            = c.ParseAvtAttribute("format");
            lang              = c.ParseAvtAttribute("lang");
            letterValue       = c.ParseAvtAttribute("letter-value");
            groupingSeparator = c.ParseAvtAttribute("grouping-separator");
            groupingSize      = c.ParseAvtAttribute("grouping-size");
        }
Exemplo n.º 12
0
		XslNumberFormatter GetNumberFormatter (XslTransformProcessor p)
		{
			string formatStr = "1";
			string lang = null;
			string letterValue = null;
			char groupingSeparatorChar = '\0';
			decimal groupingSize = 0;
			
			if (this.format != null)
				formatStr = this.format.Evaluate (p);
			
			if (this.lang != null)
				lang = this.lang.Evaluate (p);
			
			if (this.letterValue != null)
				letterValue = this.letterValue.Evaluate (p);
			
			if (groupingSeparator != null)
				groupingSeparatorChar = this.groupingSeparator.Evaluate (p) [0];
			
			if (this.groupingSize != null)
				groupingSize = decimal.Parse (this.groupingSize.Evaluate (p), CultureInfo.InvariantCulture);
			
			//FIXME: Negative test compliency: .NET throws exception on negative grouping-size
			if (groupingSize > Int32.MaxValue || groupingSize < 1)
				groupingSize = 0;

			return new XslNumberFormatter (formatStr, lang, letterValue, groupingSeparatorChar, (int)groupingSize);
		}
Exemplo n.º 13
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();
            }
        }
Exemplo n.º 14
0
		public static string AttemptPreCalc (ref XslAvt avt)
		{
			if (avt == null) return null;
			if (avt.simpleString != null) {
				string s = avt.simpleString;
				avt = null;
				return s;
			}
			return null;
		}
Exemplo n.º 15
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();
            }
        }
Exemplo n.º 16
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();
     }
 }
Exemplo n.º 17
0
		public Sort (Compiler c)
		{
			c.CheckExtraAttributes ("sort", "select", "lang", "data-type", "order", "case-order");
			
			expr = c.CompileExpression (c.GetAttribute ("select"));
			if (expr == null)
				expr = c.CompileExpression ("string(.)");
			
			langAvt = c.ParseAvtAttribute ("lang");
			dataTypeAvt = c.ParseAvtAttribute ("data-type");
			orderAvt = c.ParseAvtAttribute ("order");
			caseOrderAvt = c.ParseAvtAttribute ("case-order");
			
			// Precalc whatever we can
			lang = ParseLang (XslAvt.AttemptPreCalc (ref langAvt));
			dataType = ParseDataType (XslAvt.AttemptPreCalc (ref dataTypeAvt));
			order = ParseOrder (XslAvt.AttemptPreCalc (ref orderAvt));
			caseOrder = ParseCaseOrder (XslAvt.AttemptPreCalc (ref caseOrderAvt));
		}
        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();
            }
        }
Exemplo n.º 19
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			c.CheckExtraAttributes ("number", "level", "count", "from", "value", "format", "lang", "letter-value", "grouping-separator", "grouping-size");

			switch (c.GetAttribute ("level"))
			{
			case "single":
				level = XslNumberingLevel.Single;
				break;
			case "multiple":
				level = XslNumberingLevel.Multiple;
				break;
			case "any":
				level = XslNumberingLevel.Any;
				break;
			case null:
			case "":
			default:
				level = XslNumberingLevel.Single; // single == default
				break;
			}
			
			count = c.CompilePattern (c.GetAttribute ("count"), c.Input);
			from = c.CompilePattern (c.GetAttribute ("from"), c.Input);
			value = c.CompileExpression (c.GetAttribute ("value"));
			
			format = c.ParseAvtAttribute ("format");
			lang = c.ParseAvtAttribute ("lang");
			letterValue = c.ParseAvtAttribute ("letter-value");
			groupingSeparator = c.ParseAvtAttribute ("grouping-separator");
			groupingSize = c.ParseAvtAttribute ("grouping-size");
		}