示例#1
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("fallback");

			if (!c.Input.MoveToFirstChild ()) return;
			children = c.CompileTemplateContent ();
			c.Input.MoveToParent ();
		}
示例#2
0
文件: XslComment.cs 项目: nobled/mono
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("comment");

			if (c.Input.MoveToFirstChild ()) {
				value = c.CompileTemplateContent (XPathNodeType.Comment);
				c.Input.MoveToParent ();
			}
		}
示例#3
0
文件: XslMessage.cs 项目: nobled/mono
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			c.CheckExtraAttributes ("message", "terminate");

			terminate = c.ParseYesNoAttribute ("terminate", false);
			
			if (!c.Input.MoveToFirstChild ()) return;
			children = c.CompileTemplateContent ();
			c.Input.MoveToParent ();
		}
示例#4
0
文件: XslIf.cs 项目: 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 ();
		}	
示例#5
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 ();
		}
示例#6
0
文件: XslCopy.cs 项目: nobled/mono
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			this.nsDecls = c.GetNamespacesToCopy ();
			if (nsDecls.Count == 0)
				nsDecls = null;

			c.CheckExtraAttributes ("copy", "use-attribute-sets");

			useAttributeSets = c.ParseQNameListAttribute ("use-attribute-sets");
			
			if (!c.Input.MoveToFirstChild ()) return;
			children = c.CompileTemplateContent();
			c.Input.MoveToParent ();
		}
示例#7
0
文件: XslChoose.cs 项目: nobled/mono
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("choose");

			if (!c.Input.MoveToFirstChild ())
				throw new XsltCompileException ("Expecting non-empty element", null, c.Input);
			
			do {
				if (c.Input.NodeType != XPathNodeType.Element) continue;
				if (c.Input.NamespaceURI != XsltNamespace) continue;
				
				if (defaultChoice != null)
					throw new XsltCompileException ("otherwise attribute must be last", null, c.Input);

				switch (c.Input.LocalName) {
				case "when":
					conditions.Add (new XslIf (c));
					break;
					
				case "otherwise":
					c.CheckExtraAttributes ("otherwise");
					if (c.Input.MoveToFirstChild ()) {
						defaultChoice = c.CompileTemplateContent ();
						c.Input.MoveToParent ();
					}
					break;

				default:
					if (c.CurrentStylesheet.Version == "1.0")
						throw new XsltCompileException ("XSLT choose element accepts only when and otherwise elements", null, c.Input);
					break;
				}
			} while (c.Input.MoveToNext ());
			
			c.Input.MoveToParent ();
			
			if (conditions.Count == 0)
				throw new XsltCompileException ("Choose must have 1 or more when elements", null, c.Input);
		}
示例#8
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 ();
			}
		}
示例#9
0
文件: XslForEach.cs 项目: nobled/mono
		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)));
		}
示例#10
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 ();
			}
		}
示例#11
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			prefix = c.Input.Prefix;
			string alias = c.CurrentStylesheet.GetActualPrefix (prefix);
			if (alias != prefix) {
				prefix = alias;
				nsUri = c.Input.GetNamespace (alias);
			}
			else
				nsUri = c.Input.NamespaceURI;

			this.localname = c.Input.LocalName;
			this.useAttributeSets = c.ParseQNameListAttribute ("use-attribute-sets", XsltNamespace);
			this.nsDecls = c.GetNamespacesToCopy ();
			if (nsDecls.Count == 0) nsDecls = null;
			this.isEmptyElement = c.Input.IsEmptyElement;

			if (c.Input.MoveToFirstAttribute ())
			{
				attrs = new ArrayList ();
				do {
					if (c.Input.NamespaceURI == XsltNamespace)
						continue; //already handled
					attrs.Add (new XslLiteralAttribute (c));
				} while (c.Input.MoveToNextAttribute());
				c.Input.MoveToParent ();
			}
			
			if (!c.Input.MoveToFirstChild ()) return;
			children = c.CompileTemplateContent ();
			c.Input.MoveToParent ();
		}
示例#12
0
文件: XslElement.cs 项目: nobled/mono
		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 ();
			}
		}