コード例 #1
0
        protected override void Compile(Compiler c)
        {
            if (c.Debugger != null)
            {
                c.Debugger.DebugCompile(c.Input);
            }
            c.CheckExtraAttributes("for-each", new string[]
            {
                "select"
            });
            c.AssertAttribute("select");
            this.select = c.CompileExpression(c.GetAttribute("select"));
            ArrayList arrayList = null;

            if (c.Input.MoveToFirstChild())
            {
                bool flag = true;
                while (c.Input.NodeType != XPathNodeType.Text)
                {
                    if (c.Input.NodeType == XPathNodeType.Element)
                    {
                        if (c.Input.NamespaceURI != "http://www.w3.org/1999/XSL/Transform")
                        {
                            flag = false;
                            goto IL_104;
                        }
                        if (c.Input.LocalName != "sort")
                        {
                            flag = false;
                            goto IL_104;
                        }
                        if (arrayList == null)
                        {
                            arrayList = new ArrayList();
                        }
                        arrayList.Add(new Sort(c));
                    }
                    if (c.Input.MoveToNext())
                    {
                        continue;
                    }
IL_104:
                    if (!flag)
                    {
                        this.children = c.CompileTemplateContent();
                    }
                    c.Input.MoveToParent();
                    goto IL_122;
                }
                flag = false;
                goto IL_104;
            }
IL_122:
            if (arrayList != null)
            {
                this.sortEvaluator = new XslSortEvaluator(this.select, (Sort[])arrayList.ToArray(typeof(Sort)));
            }
        }
コード例 #2
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)));
            }
        }
コード例 #3
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)));
		}
コード例 #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)));
            }
        }
コード例 #5
0
ファイル: XslApplyTemplates.cs プロジェクト: nobled/mono
		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)));
		}
コード例 #6
0
        protected override void Compile(Compiler c)
        {
            if (c.Debugger != null)
            {
                c.Debugger.DebugCompile(c.Input);
            }
            c.CheckExtraAttributes("apply-templates", new string[]
            {
                "select",
                "mode"
            });
            this.select = c.CompileExpression(c.GetAttribute("select"));
            this.mode   = c.ParseQNameAttribute("mode");
            ArrayList arrayList = null;

            if (c.Input.MoveToFirstChild())
            {
                for (;;)
                {
                    switch (c.Input.NodeType)
                    {
                    case XPathNodeType.Element:
                    {
                        if (c.Input.NamespaceURI != "http://www.w3.org/1999/XSL/Transform")
                        {
                            goto Block_3;
                        }
                        string localName = c.Input.LocalName;
                        if (localName == null)
                        {
                            goto IL_1AF;
                        }
                        if (XslApplyTemplates.< > f__switch$map7 == null)
                        {
                            XslApplyTemplates.< > f__switch$map7 = new Dictionary <string, int>(2)
                            {
                                {
                                    "with-param",
                                    0
                                },
                                {
                                    "sort",
                                    1
                                }
                            };
                        }
                        int num;
                        if (XslApplyTemplates.< > f__switch$map7.TryGetValue(localName, out num))
                        {
                            if (num != 0)
                            {
                                if (num != 1)
                                {
                                    goto Block_8;
                                }
                                if (arrayList == null)
                                {
                                    arrayList = new ArrayList();
                                }
                                if (this.select == null)
                                {
                                    this.select = c.CompileExpression("*");
                                }
                                arrayList.Add(new Sort(c));
                            }
                            else
                            {
                                if (this.withParams == null)
                                {
                                    this.withParams = new ArrayList();
                                }
                                this.withParams.Add(new XslVariableInformation(c));
                            }
                            goto IL_1ED;
                        }
                        goto IL_1AF;
                    }

                    case XPathNodeType.SignificantWhitespace:
                    case XPathNodeType.Whitespace:
                    case XPathNodeType.ProcessingInstruction:
                    case XPathNodeType.Comment:
                        goto IL_1ED;
                    }
                    break;
IL_1ED:
                    if (!c.Input.MoveToNext())
                    {
                        goto Block_12;
                    }
                }
                goto IL_1C6;
Block_3:
                throw new XsltCompileException("Unexpected element", null, c.Input);
Block_8:
IL_1AF:
                throw new XsltCompileException("Unexpected element", null, c.Input);
IL_1C6:
                throw new XsltCompileException("Unexpected node type " + c.Input.NodeType, null, c.Input);
Block_12:
                c.Input.MoveToParent();
            }
            if (arrayList != null)
            {
                this.sortEvaluator = new XslSortEvaluator(this.select, (Sort[])arrayList.ToArray(typeof(Sort)));
            }
        }