Beispiel #1
0
 public void AddKey(XslKey key)
 {
     if (keys [key.Name] == null)
     {
         keys [key.Name] = new ArrayList();
     }
     ((ArrayList)keys [key.Name]).Add(key);
 }
		private void HandleTopLevelElement (Compiler c)
		{
			XPathNavigator n = c.Input;
			switch (n.NamespaceURI)
			{
			case XsltNamespace:
				switch (n.LocalName)
				{
				case "include":
					HandleInclude (c);
					break;
				case "preserve-space":
					AddSpaceControls (c.ParseQNameListAttribute ("elements"), XmlSpace.Preserve, n);
					break;
				
				case "strip-space":
					AddSpaceControls (c.ParseQNameListAttribute ("elements"), XmlSpace.Default, n);
					break;
				case "namespace-alias":
					// do nothing. It is handled in prior.
					break;
				
				case "attribute-set":
					c.AddAttributeSet (new XslAttributeSet (c));
					break;

				case "key":
					XslKey key = new XslKey (c);
					if (keys [key.Name] == null)
						keys [key.Name] = new ArrayList ();
					((ArrayList) keys [key.Name]).Add (key);
					break;
					
				case "output":
					c.CompileOutput ();
					break;
				
				case "decimal-format":
					c.CompileDecimalFormat ();
					break;
					
				case "template":
					templates.Add (new XslTemplate (c));	
					break;
				case "variable":
					XslGlobalVariable gvar = new XslGlobalVariable (c);
					variables [gvar.Name] = gvar;
					break;
				case "param":
					XslGlobalParam gpar = new XslGlobalParam (c);
					variables [gpar.Name] = gpar;
					break;
				default:
					if (version == "1.0")
						throw new XsltCompileException ("Unrecognized top level element after imports", null, c.Input);
					break;
				}
				break;
			case MSXsltNamespace:
				switch (n.LocalName)
				{
				case "script":
					c.ScriptManager.AddScript (c);
					break;
				}
				break;
			}
		}
Beispiel #3
0
        private void CollectTable(XPathNavigator doc, XsltContext ctx, Hashtable map, XslKey key)
        {
            XPathNavigator xpathNavigator = doc.Clone();

            xpathNavigator.MoveToRoot();
            XPathNavigator xpathNavigator2   = doc.Clone();
            bool           matchesAttributes = false;
            XPathNodeType  evaluatedNodeType = key.Match.EvaluatedNodeType;

            if (evaluatedNodeType == XPathNodeType.Attribute || evaluatedNodeType == XPathNodeType.All)
            {
                matchesAttributes = true;
            }
            do
            {
                if (key.Match.Matches(xpathNavigator, ctx))
                {
                    xpathNavigator2.MoveTo(xpathNavigator);
                    this.CollectIndex(xpathNavigator, xpathNavigator2, map);
                }
            }while (this.MoveNavigatorToNext(xpathNavigator, matchesAttributes));
            if (map != null)
            {
                foreach (object obj in map.Values)
                {
                    ArrayList arrayList = (ArrayList)obj;
                    arrayList.Sort(XPathNavigatorComparer.Instance);
                }
            }
        }
Beispiel #4
0
        private void CollectIndex(XPathNavigator nav, XPathNavigator target, Hashtable map, XslKey key)
        {
            switch (key.Use.ReturnType)
            {
            case XPathResultType.NodeSet:
            {
                XPathNodeIterator xpathNodeIterator = nav.Select(key.Use);
                while (xpathNodeIterator.MoveNext())
                {
                    XPathNavigator xpathNavigator = xpathNodeIterator.Current;
                    this.AddIndex(xpathNavigator.Value, target, map);
                }
                return;
            }

            case XPathResultType.Any:
            {
                object            obj = nav.Evaluate(key.Use);
                XPathNodeIterator xpathNodeIterator = obj as XPathNodeIterator;
                if (xpathNodeIterator != null)
                {
                    while (xpathNodeIterator.MoveNext())
                    {
                        XPathNavigator xpathNavigator2 = xpathNodeIterator.Current;
                        this.AddIndex(xpathNavigator2.Value, target, map);
                    }
                }
                else
                {
                    this.AddIndex(XPathFunctions.ToString(obj), target, map);
                }
                return;
            }
            }
            string key2 = nav.EvaluateString(key.Use, null, null);

            this.AddIndex(key2, target, map);
        }
Beispiel #5
0
        private void HandleTopLevelElement(Compiler c)
        {
            XPathNavigator n = c.Input;

            switch (n.NamespaceURI)
            {
            case XsltNamespace:
                switch (n.LocalName)
                {
                case "include":
                    HandleInclude(c);
                    break;

                case "preserve-space":
                    AddSpaceControls(c.ParseQNameListAttribute("elements"), XmlSpace.Preserve, n);
                    break;

                case "strip-space":
                    AddSpaceControls(c.ParseQNameListAttribute("elements"), XmlSpace.Default, n);
                    break;

                case "namespace-alias":
                    // do nothing. It is handled in prior.
                    break;

                case "attribute-set":
                    c.AddAttributeSet(new XslAttributeSet(c));
                    break;

                case "key":
                    XslKey key = new XslKey(c);
                    if (keys [key.Name] == null)
                    {
                        keys [key.Name] = new ArrayList();
                    }
                    ((ArrayList)keys [key.Name]).Add(key);
                    break;

                case "output":
                    c.CompileOutput();
                    break;

                case "decimal-format":
                    c.CompileDecimalFormat();
                    break;

                case "template":
                    templates.Add(new XslTemplate(c));
                    break;

                case "variable":
                    XslGlobalVariable gvar = new XslGlobalVariable(c);
                    variables [gvar.Name] = gvar;
                    break;

                case "param":
                    XslGlobalParam gpar = new XslGlobalParam(c);
                    variables [gpar.Name] = gpar;
                    break;

                default:
                    if (version == "1.0")
                    {
                        throw new XsltCompileException("Unrecognized top level element after imports", null, c.Input);
                    }
                    break;
                }
                break;

            case MSXsltNamespace:
                switch (n.LocalName)
                {
                case "script":
                    c.ScriptManager.AddScript(c);
                    break;
                }
                break;
            }
        }
		private void CollectIndex (XPathNavigator nav, XPathNavigator target, Hashtable map, XslKey key)
		{
			XPathNodeIterator iter;
			switch (key.Use.ReturnType) {
			case XPathResultType.NodeSet:
				iter = nav.Select (key.Use);
				while (iter.MoveNext ())
					AddIndex (iter.Current.Value, target, map);
				break;
			case XPathResultType.Any:
				object o = nav.Evaluate (key.Use);
				iter = o as XPathNodeIterator;
				if (iter != null) {
					while (iter.MoveNext ())
						AddIndex (iter.Current.Value, target, map);
				}
				else
					AddIndex (XPathFunctions.ToString (o), target, map);
				break;
			default:
				string keyValue = nav.EvaluateString (key.Use, null, null);
				AddIndex (keyValue, target, map);
				break;
			}
		}
		private void CollectTable (XPathNavigator doc, XsltContext ctx, Hashtable map, XslKey key)
		{
			XPathNavigator nav = doc.Clone ();
			nav.MoveToRoot ();
			XPathNavigator tmp = doc.Clone ();

			bool matchesAttributes = false;
			switch (key.Match.EvaluatedNodeType) {
			case XPathNodeType.All:
			case XPathNodeType.Attribute:
				matchesAttributes = true;
				break;
			}

			do {
				if (key.Match.Matches (nav, ctx)) {
					tmp.MoveTo (nav);
					CollectIndex (nav, tmp, map);
				}
			} while (MoveNavigatorToNext (nav, matchesAttributes));
			if (map != null)
				foreach (ArrayList list in map.Values)
					list.Sort (XPathNavigatorComparer.Instance);
		}
Beispiel #8
0
        private void CollectIndex(XPathNavigator nav, XPathNavigator target, Hashtable map, XslKey key)
        {
            XPathNodeIterator iter;

            switch (key.Use.ReturnType)
            {
            case XPathResultType.NodeSet:
                iter = nav.Select(key.Use);
                while (iter.MoveNext())
                {
                    AddIndex(iter.Current.Value, target, map);
                }
                break;

            case XPathResultType.Any:
                object o = nav.Evaluate(key.Use);
                iter = o as XPathNodeIterator;
                if (iter != null)
                {
                    while (iter.MoveNext())
                    {
                        AddIndex(iter.Current.Value, target, map);
                    }
                }
                else
                {
                    AddIndex(XPathFunctions.ToString(o), target, map);
                }
                break;

            default:
                string keyValue = nav.EvaluateString(key.Use, null, null);
                AddIndex(keyValue, target, map);
                break;
            }
        }
Beispiel #9
0
        private void CollectTable(XPathNavigator doc, XsltContext ctx, Hashtable map, XslKey key)
        {
            XPathNavigator nav = doc.Clone();

            nav.MoveToRoot();
            XPathNavigator tmp = doc.Clone();

            bool matchesAttributes = false;

            switch (key.Match.EvaluatedNodeType)
            {
            case XPathNodeType.All:
            case XPathNodeType.Attribute:
                matchesAttributes = true;
                break;
            }

            do
            {
                if (key.Match.Matches(nav, ctx))
                {
                    tmp.MoveTo(nav);
                    CollectIndex(nav, tmp, map);
                }
            } while (MoveNavigatorToNext(nav, matchesAttributes));
            if (map != null)
            {
                foreach (ArrayList list in map.Values)
                {
                    list.Sort(XPathNavigatorComparer.Instance);
                }
            }
        }
Beispiel #10
0
		public void AddKey (XslKey key)
		{
			if (keys [key.Name] == null)
				keys [key.Name] = new ArrayList ();
			((ArrayList) keys [key.Name]).Add (key);
		}
Beispiel #11
0
        private void HandleTopLevelElement(Compiler c)
        {
            XPathNavigator input        = c.Input;
            string         namespaceURI = input.NamespaceURI;

            if (namespaceURI != null)
            {
                if (XslStylesheet.< > f__switch$map26 == null)
                {
                    XslStylesheet.< > f__switch$map26 = new Dictionary <string, int>(2)
                    {
                        {
                            "http://www.w3.org/1999/XSL/Transform",
                            0
                        },
                        {
                            "urn:schemas-microsoft-com:xslt",
                            1
                        }
                    };
                }
                int num;
                if (XslStylesheet.< > f__switch$map26.TryGetValue(namespaceURI, out num))
                {
                    if (num != 0)
                    {
                        if (num == 1)
                        {
                            string localName = input.LocalName;
                            if (localName != null)
                            {
                                if (XslStylesheet.< > f__switch$map25 == null)
                                {
                                    XslStylesheet.< > f__switch$map25 = new Dictionary <string, int>(1)
                                    {
                                        {
                                            "script",
                                            0
                                        }
                                    };
                                }
                                int num2;
                                if (XslStylesheet.< > f__switch$map25.TryGetValue(localName, out num2))
                                {
                                    if (num2 == 0)
                                    {
                                        c.ScriptManager.AddScript(c);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        string localName = input.LocalName;
                        switch (localName)
                        {
                        case "include":
                            this.HandleInclude(c);
                            goto IL_2B0;

                        case "preserve-space":
                            this.AddSpaceControls(c.ParseQNameListAttribute("elements"), XmlSpace.Preserve, input);
                            goto IL_2B0;

                        case "strip-space":
                            this.AddSpaceControls(c.ParseQNameListAttribute("elements"), XmlSpace.Default, input);
                            goto IL_2B0;

                        case "namespace-alias":
                            goto IL_2B0;

                        case "attribute-set":
                            c.AddAttributeSet(new XslAttributeSet(c));
                            goto IL_2B0;

                        case "key":
                        {
                            XslKey xslKey = new XslKey(c);
                            if (this.keys[xslKey.Name] == null)
                            {
                                this.keys[xslKey.Name] = new ArrayList();
                            }
                            ((ArrayList)this.keys[xslKey.Name]).Add(xslKey);
                            goto IL_2B0;
                        }

                        case "output":
                            c.CompileOutput();
                            goto IL_2B0;

                        case "decimal-format":
                            c.CompileDecimalFormat();
                            goto IL_2B0;

                        case "template":
                            this.templates.Add(new XslTemplate(c));
                            goto IL_2B0;

                        case "variable":
                        {
                            XslGlobalVariable xslGlobalVariable = new XslGlobalVariable(c);
                            this.variables[xslGlobalVariable.Name] = xslGlobalVariable;
                            goto IL_2B0;
                        }

                        case "param":
                        {
                            XslGlobalParam xslGlobalParam = new XslGlobalParam(c);
                            this.variables[xslGlobalParam.Name] = xslGlobalParam;
                            goto IL_2B0;
                        }
                        }
                        if (this.version == "1.0")
                        {
                            throw new XsltCompileException("Unrecognized top level element after imports", null, c.Input);
                        }
                        IL_2B0 :;
                    }
                }
            }
        }