Exemplo n.º 1
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			c.CheckExtraAttributes ("value-of", "select", "disable-output-escaping");

			c.AssertAttribute ("select");
			select = c.CompileExpression (c.GetAttribute ("select"));
			disableOutputEscaping = c.ParseYesNoAttribute ("disable-output-escaping", false);
			if (c.Input.MoveToFirstChild ()) {
				do {
					switch (c.Input.NodeType) {
					case XPathNodeType.Element:
						if (c.Input.NamespaceURI == XsltNamespace)
							goto case XPathNodeType.SignificantWhitespace;
						// otherwise element in external namespace -> ignore
						break;
					case XPathNodeType.Text:
					case XPathNodeType.SignificantWhitespace:
						throw new XsltCompileException ("XSLT value-of element cannot contain any child.", null, c.Input);
					}
				} while (c.Input.MoveToNext ());
			}
		}
Exemplo n.º 2
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");
		}
Exemplo n.º 3
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("copy-of", "select");

			c.AssertAttribute ("select");
			select = c.CompileExpression (c.GetAttribute ("select"));
		}
Exemplo n.º 4
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("apply-templates", "select", "mode");

			select = c.CompileExpression (c.GetAttribute ("select"));
			mode = c.ParseQNameAttribute ("mode");
			ArrayList sorterList = null;
			if (c.Input.MoveToFirstChild ()) {
				do {
					switch (c.Input.NodeType) {
					case XPathNodeType.Comment:
					case XPathNodeType.ProcessingInstruction:
					case XPathNodeType.Whitespace:
					case XPathNodeType.SignificantWhitespace:
						continue;
					case XPathNodeType.Element:
						if (c.Input.NamespaceURI != XsltNamespace)
							throw new XsltCompileException ("Unexpected element", null, c.Input); // TODO: fwd compat
						
						switch (c.Input.LocalName)
						{
							case "with-param":
								if (withParams == null)
									withParams = new ArrayList ();
								withParams.Add (new XslVariableInformation (c));
								break;
								
							case "sort":
								if (sorterList == null)
									sorterList = new ArrayList ();
								if (select == null)
									select = c.CompileExpression ("*");
								sorterList.Add (new Sort (c));
								//c.AddSort (select, new Sort (c));
								break;
							default:
								throw new XsltCompileException ("Unexpected element", null, c.Input); // todo forwards compat
						}
						break;
					default:
						throw new XsltCompileException ("Unexpected node type " + c.Input.NodeType, null, c.Input);	// todo forwards compat
					}
				} while (c.Input.MoveToNext ());
				c.Input.MoveToParent ();
			}
			if (sorterList != null)
				sortEvaluator = new XslSortEvaluator (select,
					(Sort []) sorterList.ToArray (typeof (Sort)));
		}
Exemplo n.º 5
0
		public XslVariableInformation (Compiler c)
		{

			c.CheckExtraAttributes (c.Input.LocalName, "name", "select");

			c.AssertAttribute ("name");

			name = c.ParseQNameAttribute ("name");
			try {
				XmlConvert.VerifyName (name.Name);
			} catch (XmlException ex) {
				throw new XsltCompileException ("Variable name is not qualified name", ex, c.Input);
			}

			string sel = c.GetAttribute ("select");
			if (sel != null && sel != "" ) {
				select = c.CompileExpression (c.GetAttribute ("select"));
				// TODO assert empty
			} else  if (c.Input.MoveToFirstChild ()) {
				content = c.CompileTemplateContent ();
				c.Input.MoveToParent ();
			}
		}
Exemplo n.º 6
0
Arquivo: XslIf.cs Projeto: nobled/mono
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("if", "test");

			c.AssertAttribute ("test");
			test = c.CompileExpression (c.GetAttribute ("test"));

			if (!c.Input.MoveToFirstChild ()) return;
			children = c.CompileTemplateContent ();
			c.Input.MoveToParent ();
		}	
Exemplo n.º 7
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("for-each", "select");

			c.AssertAttribute ("select");
			select = c.CompileExpression (c.GetAttribute ("select"));
			ArrayList sorterList = null;
			
			if (c.Input.MoveToFirstChild ()) {
				bool alldone = true;
				do {
					if (c.Input.NodeType == XPathNodeType.Text)
						{ alldone = false; break; }
					
					if (c.Input.NodeType != XPathNodeType.Element)
						continue;
					if (c.Input.NamespaceURI != Compiler.XsltNamespace)
						{ alldone = false; break; }
					if (c.Input.LocalName != "sort")
						{ alldone = false; break; }
					//c.AddSort (select, new Sort (c));
					if (sorterList == null)
						sorterList = new ArrayList ();
					sorterList.Add (new Sort (c));
				} while (c.Input.MoveToNext ());
				if (!alldone)
					children = c.CompileTemplateContent ();
				c.Input.MoveToParent ();
			}
			if (sorterList != null)
				sortEvaluator = new XslSortEvaluator (select,
					(Sort []) sorterList.ToArray (typeof (Sort)));
		}