Esempio n. 1
0
        private XPathNodeIterator GetDocument(XsltCompiledContext xsltContext, XPathNodeIterator itr, string baseUri)
        {
            ArrayList arrayList = new ArrayList();

            try
            {
                Hashtable hashtable = new Hashtable();
                while (itr.MoveNext())
                {
                    XPathNavigator xpathNavigator = itr.Current;
                    Uri            uri            = this.Resolve(xpathNavigator.Value, (baseUri == null) ? this.doc.BaseURI : baseUri, xsltContext.Processor);
                    if (!hashtable.ContainsKey(uri))
                    {
                        hashtable.Add(uri, null);
                        if (uri != null && uri.ToString() == string.Empty)
                        {
                            XPathNavigator xpathNavigator2 = this.doc.Clone();
                            xpathNavigator2.MoveToRoot();
                            arrayList.Add(xpathNavigator2);
                        }
                        else
                        {
                            arrayList.Add(xsltContext.Processor.GetDocument(uri));
                        }
                    }
                }
            }
            catch (Exception)
            {
                arrayList.Clear();
            }
            return(new ListIterator(arrayList, xsltContext));
        }
Esempio n. 2
0
        public override object Evaluate(BaseIterator iter)
        {
            XsltCompiledContext ctx = iter.NamespaceManager
                                      as XsltCompiledContext;

            return(ctx.EvaluateKey(staticContext, iter, arg0, arg1));
        }
Esempio n. 3
0
        private XPathNodeIterator GetDocument(XsltCompiledContext xsltContext, string arg0, string baseUri)
        {
            XPathNodeIterator result;

            try
            {
                Uri            uri = this.Resolve(arg0, (baseUri == null) ? this.doc.BaseURI : baseUri, xsltContext.Processor);
                XPathNavigator xpathNavigator;
                if (uri != null && uri.ToString() == string.Empty)
                {
                    xpathNavigator = this.doc.Clone();
                    xpathNavigator.MoveToRoot();
                }
                else
                {
                    xpathNavigator = xsltContext.Processor.GetDocument(uri);
                }
                result = new SelfIterator(xpathNavigator, xsltContext);
            }
            catch (Exception)
            {
                result = new ListIterator(new ArrayList(), xsltContext);
            }
            return(result);
        }
Esempio n. 4
0
        XPathNodeIterator GetDocument(XsltCompiledContext xsltContext, XPathNodeIterator itr, string baseUri)
        {
            ArrayList list = new ArrayList();

            try {
                Hashtable got = new Hashtable();

                while (itr.MoveNext())
                {
                    Uri uri = Resolve(itr.Current.Value, baseUri != null ? baseUri : /*itr.Current.BaseURI*/ doc.BaseURI, xsltContext.Processor);
                    if (!got.ContainsKey(uri))
                    {
                        got.Add(uri, null);
                        if (uri != null && uri.ToString() == "")
                        {
                            XPathNavigator n = doc.Clone();
                            n.MoveToRoot();
                            list.Add(n);
                        }
                        else
                        {
                            list.Add(xsltContext.Processor.GetDocument(uri));
                        }
                    }
                }
            } catch (Exception) {
                // Error recovery.
                // See http://www.w3.org/TR/xslt#document and
                // bug #75663.
                list.Clear();
            }
            return(new ListIterator(list, xsltContext));
        }
        public override object Invoke(XsltCompiledContext xsltContext, object [] args, XPathNavigator docContext)
        {
            try
            {
                ParameterInfo [] pis        = method.GetParameters();
                object []        castedArgs = new object [pis.Length];
                for (int i = 0; i < args.Length; i++)
                {
                    Type t = pis [i].ParameterType;
                    switch (t.FullName)
                    {
                    case "System.Int16":
                    case "System.UInt16":
                    case "System.Int32":
                    case "System.UInt32":
                    case "System.Int64":
                    case "System.UInt64":
                    case "System.Single":
                    case "System.Decimal":
                        castedArgs [i] = Convert.ChangeType(args [i], t);
                        break;

                    default:
                        castedArgs [i] = args [i];
                        break;
                    }
                }

                object result = null;
                switch (method.ReturnType.FullName)
                {
                case "System.Int16":
                case "System.UInt16":
                case "System.Int32":
                case "System.UInt32":
                case "System.Int64":
                case "System.UInt64":
                case "System.Single":
                case "System.Decimal":
                    result = Convert.ChangeType(method.Invoke(extension, castedArgs), typeof(double));
                    break;

                default:
                    result = method.Invoke(extension, castedArgs);
                    break;
                }
                IXPathNavigable navigable = result as IXPathNavigable;
                if (navigable != null)
                {
                    return(navigable.CreateNavigator());
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw new XsltException("Custom function reported an error.", ex);
//				Debug.WriteLine ("****** INCORRECT RESOLUTION **********");
            }
        }
Esempio n. 6
0
		public XslTransformProcessor (CompiledStylesheet style, object debugger)
		{
			this.XPathContext = new XsltCompiledContext (this);
			this.compiledStyle = style;
			this.style = style.Style;
			if (debugger != null)
				this.debugger = new XsltDebuggerWrapper (debugger);
		}
Esempio n. 7
0
        public bool PatternMatches(XPathNavigator nav, XsltContext nsmgr)
        {
            XsltCompiledContext ctx = nsmgr as XsltCompiledContext;

            // for key pattern, it must contain literal value
            return(ctx.MatchesKey(nav, staticContext,
                                  arg0.StaticValueAsString,
                                  arg1.StaticValueAsString));
        }
Esempio n. 8
0
 public XslTransformProcessor(CompiledStylesheet style, object debugger)
 {
     this.XPathContext  = new XsltCompiledContext(this);
     this.compiledStyle = style;
     this.style         = style.Style;
     if (debugger != null)
     {
         this.debugger = new XsltDebuggerWrapper(debugger);
     }
 }
        public override object Evaluate(BaseIterator iter)
        {
            XsltCompiledContext nsm             = iter.NamespaceManager as XsltCompiledContext;
            XPathNavigator      xpathNavigator  = (iter.Current == null) ? null : iter.Current.Clone();
            XPathNavigator      xpathNavigator2 = this.arg0.EvaluateAs(iter, XPathResultType.Navigator) as XPathNavigator;

            if (xpathNavigator2 != null)
            {
                return(new ListIterator(new ArrayList
                {
                    xpathNavigator2
                }, nsm));
            }
            if (xpathNavigator != null)
            {
                return(new XsltException("Cannot convert the XPath argument to a result tree fragment.", null, xpathNavigator));
            }
            return(new XsltException("Cannot convert the XPath argument to a result tree fragment.", null));
        }
Esempio n. 10
0
        public override object Evaluate(BaseIterator iter)
        {
            XsltCompiledContext ctx = iter.NamespaceManager as XsltCompiledContext;
            XPathNavigator      loc = iter.Current != null?iter.Current.Clone() : null;

            object val = arg0.Evaluate(iter);

            XPathNavigator nav = val as XPathNavigator;

            if (nav == null && !strict)
            {
                var iterResult = val as XPathNodeIterator;
                if (iterResult != null)
                {
                    return(iterResult);
                }

                var strResult = val as string;
                if (strResult == string.Empty)
                {
                    DTMXPathDocumentWriter2 w = new DTMXPathDocumentWriter2(ctx.Processor.Root.NameTable, 10);
                    nav = w.CreateDocument().CreateNavigator();
                }
            }

            if (nav == null)
            {
                if (loc != null)
                {
                    return(new XsltException("Cannot convert the XPath argument to a result tree fragment.", null, loc));
                }
                else
                {
                    return(new XsltException("Cannot convert the XPath argument to a result tree fragment.", null));
                }
            }

            ArrayList al = new ArrayList();

            al.Add(nav);
            return(new ListIterator(al, ctx));
        }
Esempio n. 11
0
        XPathNodeIterator GetDocument(XsltCompiledContext xsltContext, string arg0, string baseUri)
        {
            try {
                Uri            uri = Resolve(arg0, baseUri != null ? baseUri : doc.BaseURI, xsltContext.Processor);
                XPathNavigator n;
                if (uri != null && uri.ToString() == "")
                {
                    n = doc.Clone();
                    n.MoveToRoot();
                }
                else
                {
                    n = xsltContext.Processor.GetDocument(uri);
                }

                return(new SelfIterator(n, xsltContext));
            } catch (Exception) {
                return(new ListIterator(new ArrayList(), xsltContext));
            }
        }
Esempio n. 12
0
        public override object Evaluate(BaseIterator iter)
        {
            XsltCompiledContext ctx = iter.NamespaceManager as XsltCompiledContext;
            XPathNavigator      loc = iter.Current != null?iter.Current.Clone() : null;

            XPathNavigator nav = arg0.EvaluateAs(iter, XPathResultType.Navigator) as XPathNavigator;

            if (nav == null)
            {
                if (loc != null)
                {
                    return(new XsltException("Cannot convert the XPath argument to a result tree fragment.", null, loc));
                }
                else
                {
                    return(new XsltException("Cannot convert the XPath argument to a result tree fragment.", null));
                }
            }
            ArrayList al = new ArrayList();

            al.Add(nav);
            return(new ListIterator(al, ctx));
        }
Esempio n. 13
0
        public override object Evaluate(BaseIterator iter)
        {
            XsltCompiledContext xsltCompiledContext = iter.NamespaceManager as XsltCompiledContext;

            return(xsltCompiledContext.EvaluateKey(this.staticContext, iter, this.arg0, this.arg1));
        }
Esempio n. 14
0
        public override object Evaluate(BaseIterator iter)
        {
            XsltCompiledContext ctx = (XsltCompiledContext)iter.NamespaceManager;

            return(new SelfIterator((ctx).Processor.CurrentNode, ctx));
        }
		public abstract object Invoke (XsltCompiledContext xsltContext, object [] args, XPathNavigator docContext);
		XPathNodeIterator GetDocument (XsltCompiledContext xsltContext, string arg0, string baseUri)
		{
			try {
				Uri uri = Resolve (arg0, baseUri != null ? baseUri : doc.BaseURI, xsltContext.Processor);
				XPathNavigator n;
				if (uri != null && uri.ToString () == "") {
					n = doc.Clone ();
					n.MoveToRoot ();
				} else
					n = xsltContext.Processor.GetDocument (uri);
			
				return new SelfIterator (n, xsltContext);
			} catch (Exception) {
				return new ListIterator (new ArrayList (), xsltContext);
			}
		}
		XPathNodeIterator GetDocument (XsltCompiledContext xsltContext, XPathNodeIterator itr, string baseUri)
		{
			ArrayList list = new ArrayList ();
			try {
				Hashtable got = new Hashtable ();
			
				while (itr.MoveNext()) {
					Uri uri = Resolve (itr.Current.Value, baseUri != null ? baseUri : /*itr.Current.BaseURI*/doc.BaseURI, xsltContext.Processor);
					if (!got.ContainsKey (uri)) {
						got.Add (uri, null);
						if (uri != null && uri.ToString () == "") {
							XPathNavigator n = doc.Clone ();
							n.MoveToRoot ();
							list.Add (n);
						} else
							list.Add (xsltContext.Processor.GetDocument (uri));
					}
				}
			} catch (Exception) {
				// Error recovery.
				// See http://www.w3.org/TR/xslt#document and
				// bug #75663.
				list.Clear ();
			}
			return new ListIterator (list, xsltContext);
		}
		public override object Invoke (XsltCompiledContext xsltContext, object [] args, XPathNavigator docContext)
		{
			try {
				ParameterInfo [] pis = method.GetParameters ();
				object [] castedArgs = new object [pis.Length];
				for (int i = 0; i < args.Length; i++) {
					Type t = pis [i].ParameterType;
					switch (t.FullName) {
					case "System.Int16":
					case "System.UInt16":
					case "System.Int32":
					case "System.UInt32":
					case "System.Int64":
					case "System.UInt64":
					case "System.Single":
					case "System.Decimal":
						castedArgs [i] = Convert.ChangeType (args [i], t);
						break;
					default:
						castedArgs [i] = args [i];
						break;
					}
				}

				object result = null;
				switch (method.ReturnType.FullName) {
				case "System.Int16":
				case "System.UInt16":
				case "System.Int32":
				case "System.UInt32":
				case "System.Int64":
				case "System.UInt64":
				case "System.Single":
				case "System.Decimal":
					result = Convert.ChangeType (method.Invoke (extension, castedArgs), typeof (double));
					break;
				default:
					result = method.Invoke(extension, castedArgs);
					break;
				}
				IXPathNavigable navigable = result as IXPathNavigable;
				if (navigable != null)
					return navigable.CreateNavigator ();

				return result;
			} catch (Exception ex) {
				throw new XsltException ("Custom function reported an error.", ex);
//				Debug.WriteLine ("****** INCORRECT RESOLUTION **********");
			}
		}
Esempio n. 19
0
        public bool PatternMatches(XPathNavigator nav, XsltContext nsmgr)
        {
            XsltCompiledContext xsltCompiledContext = nsmgr as XsltCompiledContext;

            return(xsltCompiledContext.MatchesKey(nav, this.staticContext, this.arg0.StaticValueAsString, this.arg1.StaticValueAsString));
        }
Esempio n. 20
0
		public KeyIndexTable (XsltCompiledContext ctx, ArrayList keys)
		{
			this.ctx = ctx;
			this.keys = keys;
		}
        public override object Invoke(XsltCompiledContext xsltContext, object[] args, XPathNavigator docContext)
        {
            object result;

            try
            {
                ParameterInfo[] parameters = this.method.GetParameters();
                object[]        array      = new object[parameters.Length];
                int             i          = 0;
                string          fullName;
                while (i < args.Length)
                {
                    Type parameterType = parameters[i].ParameterType;
                    fullName = parameterType.FullName;
                    if (fullName == null)
                    {
                        goto IL_E5;
                    }
                    if (XsltExtensionFunction.< > f__switch$map1C == null)
                    {
                        XsltExtensionFunction.< > f__switch$map1C = new Dictionary <string, int>(8)
                        {
                            {
                                "System.Int16",
                                0
                            },
                            {
                                "System.UInt16",
                                0
                            },
                            {
                                "System.Int32",
                                0
                            },
                            {
                                "System.UInt32",
                                0
                            },
                            {
                                "System.Int64",
                                0
                            },
                            {
                                "System.UInt64",
                                0
                            },
                            {
                                "System.Single",
                                0
                            },
                            {
                                "System.Decimal",
                                0
                            }
                        };
                    }
                    int num;
                    if (!XsltExtensionFunction.< > f__switch$map1C.TryGetValue(fullName, out num))
                    {
                        goto IL_E5;
                    }
                    if (num != 0)
                    {
                        goto IL_E5;
                    }
                    array[i] = Convert.ChangeType(args[i], parameterType);
IL_F0:
                    i++;
                    continue;
IL_E5:
                    array[i] = args[i];
                    goto IL_F0;
                }
                fullName = this.method.ReturnType.FullName;
                object obj;
                if (fullName != null)
                {
                    if (XsltExtensionFunction.< > f__switch$map1D == null)
                    {
                        XsltExtensionFunction.< > f__switch$map1D = new Dictionary <string, int>(8)
                        {
                            {
                                "System.Int16",
                                0
                            },
                            {
                                "System.UInt16",
                                0
                            },
                            {
                                "System.Int32",
                                0
                            },
                            {
                                "System.UInt32",
                                0
                            },
                            {
                                "System.Int64",
                                0
                            },
                            {
                                "System.UInt64",
                                0
                            },
                            {
                                "System.Single",
                                0
                            },
                            {
                                "System.Decimal",
                                0
                            }
                        };
                    }
                    int num;
                    if (XsltExtensionFunction.< > f__switch$map1D.TryGetValue(fullName, out num))
                    {
                        if (num == 0)
                        {
                            obj = Convert.ChangeType(this.method.Invoke(this.extension, array), typeof(double));
                            goto IL_1FA;
                        }
                    }
                }
                obj = this.method.Invoke(this.extension, array);
IL_1FA:
                IXPathNavigable ixpathNavigable = obj as IXPathNavigable;
                if (ixpathNavigable != null)
                {
                    result = ixpathNavigable.CreateNavigator();
                }
                else
                {
                    result = obj;
                }
            }
            catch (Exception innerException)
            {
                throw new XsltException("Custom function reported an error.", innerException);
            }
            return(result);
        }
Esempio n. 22
0
 public abstract object Invoke(XsltCompiledContext xsltContext, object [] args, XPathNavigator docContext);
Esempio n. 23
0
 public KeyIndexTable(XsltCompiledContext ctx, ArrayList keys)
 {
     this.ctx  = ctx;
     this.keys = keys;
 }