Beispiel #1
0
 public AncestorOrSelfIterator(BaseIterator iter) : base(iter)
 {
     startPosition = iter.Current.Clone();
 }
		public override object Evaluate (BaseIterator iter)
		{
			
			string name = arg0.EvaluateString (iter);
			int colon = name.IndexOf (':');
			// extension function
			if (colon > 0)
				return (iter.NamespaceManager as XsltCompiledContext).ResolveFunction (
					XslNameUtil.FromString (name, ctx),
					null) != null;
			
			return (
				//
				// XPath
				//
                                name == "boolean" ||
                                name == "ceiling" ||
                                name == "concat" ||
                                name == "contains" ||
                                name == "count" ||
                                name == "false" ||
                                name == "floor" ||
                                name == "id"||
                                name == "lang" ||
                                name == "last" ||
                                name == "local-name" ||
                                name == "name" ||
                                name == "namespace-uri" ||
                                name == "normalize-space" ||
                                name == "not" ||
                                name == "number" ||
                                name == "position" ||
                                name == "round" ||
                                name == "starts-with" ||
                                name == "string" ||
                                name == "string-length" ||
                                name == "substring" ||
                                name == "substring-after" ||
                                name == "substring-before" ||
                                name == "sum" ||
                                name == "translate" ||
                                name == "true" ||
				// XSLT
				name == "document" ||
				name == "format-number" ||
				name == "function-available" ||
				name == "generate-id" ||
				name == "key" ||
				name == "current" ||
				name == "unparsed-entity-uri" ||
				name == "element-available" ||
				name == "system-property"
			);
		}
		public override object Evaluate (BaseIterator iter)
		{
			IHasXmlNode xn = iter.Current as IHasXmlNode;
			if (xn == null)
				return String.Empty;
			XmlNode n = xn.GetNode ();
			if (n.OwnerDocument == null)
				return String.Empty;
			XmlDocumentType doctype = n.OwnerDocument.DocumentType;
			if (doctype == null)
				return String.Empty;
			XmlEntity ent = doctype.Entities.GetNamedItem (arg0.EvaluateString (iter)) as XmlEntity;
			if (ent == null)
				return String.Empty;
			return ent.SystemId != null ? ent.SystemId : String.Empty;
		}
Beispiel #4
0
		public override object Evaluate (BaseIterator iter)
		{
			string s0 = arg0.EvaluateString (iter);
			string s1 = arg1.EvaluateString (iter);
			string s2 = arg2.EvaluateString (iter);
			
			StringBuilder ret = new StringBuilder (s0.Length);
				
			int pos = 0, len = s0.Length, s2len = s2.Length;
			
			while (pos < len) {
				int idx = s1.IndexOf (s0 [pos]);
				
				if (idx != -1) {
					if (idx < s2len)
						ret.Append (s2 [idx]);
				}
				else
					ret.Append (s0 [pos]);
				
				pos++;
			}
			
			return ret.ToString ();
		}
		public override object Evaluate (BaseIterator iter)
		{
			XsltCompiledContext ctx = (XsltCompiledContext) iter.NamespaceManager;
			return new SelfIterator ((ctx).Processor.CurrentNode, ctx);
		}
Beispiel #6
0
		public override object Evaluate (BaseIterator iter)
		{
			StringBuilder sb = new StringBuilder ();
			
			int len = rgs.Count;
			for (int i = 0; i < len; i++)
				sb.Append (((Expression)rgs[i]).EvaluateString (iter));
			
			return sb.ToString ();
		}
Beispiel #7
0
		public override object Evaluate (BaseIterator iter)
		{
			string str = arg0.EvaluateString (iter);
			double ich = Math.Round (arg1.EvaluateNumber (iter)) - 1;
			if (Double.IsNaN (ich) ||
				Double.IsNegativeInfinity (ich) ||
				ich >= (double) str.Length)
				return "";

			if (arg2 == null)
			{
				if (ich < 0)
					ich = 0.0;
				return str.Substring ((int) ich);
			}
			else
			{
				double cch = Math.Round (arg2.EvaluateNumber (iter));
				if (Double.IsNaN (cch))
					return "";
				if (ich < 0.0 || cch < 0.0) 
				{
					cch = ich + cch;
					if (cch <= 0.0)
						return "";
					ich = 0.0;
				}
				double cchMax = (double) str.Length - ich;
				if (cch > cchMax)
					cch = cchMax;
				return str.Substring ((int) ich, (int) cch);
			}
		}
 public double EvaluateNumber(BaseIterator iter)
 {
     return(this._expr.EvaluateNumber(iter));
 }
 public string EvaluateString(BaseIterator iter)
 {
     return(this._expr.EvaluateString(iter));
 }
Beispiel #10
0
 public NamespaceIterator(BaseIterator iter) : base(iter)
 {
 }
Beispiel #11
0
 public AttributeIterator(BaseIterator iter) : base(iter)
 {
 }
Beispiel #12
0
 public PrecedingIterator(BaseIterator iter) : base(iter)
 {
     startPosition = iter.Current.Clone();
 }
Beispiel #13
0
 public FollowingIterator(BaseIterator iter) : base(iter)
 {
 }
Beispiel #14
0
 public DescendantOrSelfIterator(BaseIterator iter) : base(iter)
 {
 }
Beispiel #15
0
		public override bool EvaluateBoolean (BaseIterator iter)
		{
			if (arg0.GetReturnType (iter) == XPathResultType.NodeSet)
				return arg0.EvaluateBoolean (iter);
			
			return arg0.EvaluateNodeSet (iter).MoveNext ();
		}
 public bool EvaluateBoolean(BaseIterator iter)
 {
     return(this._expr.EvaluateBoolean(iter));
 }
Beispiel #17
0
		public override object Evaluate (BaseIterator iter)
		{
			if (arg0 == null)
				return iter.Current.Name;
			
			BaseIterator argNs = arg0.EvaluateNodeSet (iter);
			if (argNs == null || !argNs.MoveNext ())
				return "";
			return argNs.Current.Name;
		}
Beispiel #18
0
 public override object Evaluate(BaseIterator iter)
 {
     return(false);
 }
Beispiel #19
0
		public override object Evaluate (BaseIterator iter)
		{
			return arg0.EvaluateString (iter).IndexOf (arg1.EvaluateString (iter)) != -1;
		}
Beispiel #20
0
 public override object Evaluate(BaseIterator iter)
 {
     return(Math.Ceiling(arg0.EvaluateNumber(iter)));
 }
Beispiel #21
0
		public override object Evaluate (BaseIterator iter)
		{
			string str;
			if (arg0 != null)
				str = arg0.EvaluateString (iter);
			else
				str = iter.Current.Value;
			System.Text.StringBuilder sb = new System.Text.StringBuilder ();
			bool fSpace = false;
			for (int i = 0; i < str.Length; i++) {
				char ch = str [i];
				if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n')
				{
					fSpace = true;
				}
				else
				{
					if (fSpace)
					{
						fSpace = false;
						if (sb.Length > 0)
							sb.Append (' ');
					}
					sb.Append (ch);
				}
			}
			return sb.ToString ();
		}
Beispiel #22
0
 public override object Evaluate(BaseIterator iter)
 {
     return(Round(arg0.EvaluateNumber(iter)));
 }
Beispiel #23
0
		public override object Evaluate (BaseIterator iter)
		{
			return !arg0.EvaluateBoolean (iter);
		}
Beispiel #24
0
 public override object Evaluate(BaseIterator iter)
 {
     return((double)iter.ComparablePosition);
 }
		public override object Evaluate (BaseIterator iter)
		{
			QName name = XslNameUtil.FromString (arg0.EvaluateString (iter), ctx);

			return (
				(name.Namespace == Compiler.XsltNamespace) &&
				(
					//
					// A list of all the instructions (does not include top-level-elements)
					//
					name.Name == "apply-imports" ||
					name.Name == "apply-templates" ||
					name.Name == "call-template" ||
					name.Name == "choose" ||
					name.Name == "comment" ||
					name.Name == "copy" ||
					name.Name == "copy-of" ||
					name.Name == "element" ||
					name.Name == "fallback" ||
					name.Name == "for-each" ||
					name.Name == "message" ||
					name.Name == "number" ||
					name.Name == "processing-instruction" ||
					name.Name == "text" ||
					name.Name == "value-of" ||
					name.Name == "variable"
				)
			);
		}
Beispiel #26
0
 public override object Evaluate(BaseIterator iter)
 {
     return((double)arg0.EvaluateNodeSet(iter).Count);
 }
		public override object Evaluate (BaseIterator iter)
		{
			XsltCompiledContext ctx = iter.NamespaceManager
				as XsltCompiledContext;
			return ctx.EvaluateKey (staticContext, iter, arg0, arg1);
		}
Beispiel #28
0
 public override object Evaluate(BaseIterator iter)
 {
     return(arg0.EvaluateString(iter).StartsWith(arg1.EvaluateString(iter)));
 }
Beispiel #29
0
		public override XPathResultType GetReturnType (BaseIterator iter)
		{
			return XPathResultType.Any;
		}
Beispiel #30
0
 public override object Evaluate(BaseIterator iter)
 {
     return(arg0.EvaluateString(iter).IndexOf(arg1.EvaluateString(iter)) != -1);
 }
Beispiel #31
0
		public override object Evaluate (BaseIterator iter)
		{
			return (double) arg0.EvaluateNodeSet (iter).Count;
		}
Beispiel #32
0
 public static bool ToBoolean(BaseIterator iter)
 {
     return(iter != null && iter.MoveNext());
 }
Beispiel #33
0
		public override object Evaluate (BaseIterator iter)
		{
			String strArgs;
			object val = arg0.Evaluate (iter);
			
			XPathNodeIterator valItr = val as XPathNodeIterator;
			if (valItr != null)
			{
				strArgs = "";
				while (valItr.MoveNext ())
					strArgs += valItr.Current.Value + " ";
			}
			else
				strArgs = XPathFunctions.ToString (val);
			
			XPathNavigator n = iter.Current.Clone ();
			ArrayList rgNodes = new ArrayList ();
			string [] ids = strArgs.Split (rgchWhitespace);
			for (int i = 0; i < ids.Length; i++)
				if (n.MoveToId (ids [i]))
					rgNodes.Add (n.Clone ());

			rgNodes.Sort (XPathNavigatorComparer.Instance);
			return new ListIterator (iter, rgNodes);
		}
Beispiel #34
0
 public override bool EvaluateBoolean(BaseIterator iter)
 {
     return(this._left.EvaluateBoolean(iter) || this._right.EvaluateBoolean(iter));
 }
Beispiel #35
0
		public override object Evaluate (BaseIterator iter)
		{
			if (arg0 == null)
				return iter.Current.Value;
			return arg0.EvaluateString (iter);
		}
 public override object Evaluate(BaseIterator iter)
 {
     return((double)iter.Count);
 }
Beispiel #37
0
		public override object Evaluate (BaseIterator iter)
		{
			return arg0.EvaluateString (iter).StartsWith (arg1.EvaluateString (iter));
		}
Beispiel #38
0
 public ParentIterator(BaseIterator iter) : base(iter)
 {
     this.canMove = this._nav.MoveToParent();
 }
Beispiel #39
0
		public override object Evaluate (BaseIterator iter)
		{
			string str1 = arg0.EvaluateString (iter);
			string str2 = arg1.EvaluateString (iter);
			int ich = str1.IndexOf (str2);
			if (ich < 0)
				return "";
			return str1.Substring (ich + str2.Length);
		}
 public virtual XPathResultType GetReturnType(BaseIterator iter)
 {
     return(this.ReturnType);
 }
Beispiel #41
0
		public override object Evaluate (BaseIterator iter)
		{
			string str;
			if (arg0 != null)
				str = arg0.EvaluateString (iter);
			else
				str = iter.Current.Value;
			return (double) str.Length;
		}
 public abstract object Evaluate(BaseIterator iter);
Beispiel #43
0
		public static bool ToBoolean (BaseIterator iter)
		{
			return iter != null && iter.MoveNext ();
		}
Beispiel #44
0
 public override double EvaluateNumber(BaseIterator iter)
 {
     return(this._left.EvaluateNumber(iter) + this._right.EvaluateNumber(iter));
 }
Beispiel #45
0
		public override object Evaluate (BaseIterator iter)
		{
			if (arg0 == null)
				return XPathFunctions.ToBoolean (iter.Current.Value);
			return arg0.EvaluateBoolean (iter);
		}
 public override object Evaluate(BaseIterator iter)
 {
     return(this.EvaluateBoolean(iter));
 }
Beispiel #47
0
		public override object Evaluate (BaseIterator iter)
		{
			return false;
		}
Beispiel #48
0
 public override object Evaluate(BaseIterator iter)
 {
     return(this._value);
 }
		public override object Evaluate (BaseIterator iter)
		{
			string baseUri = null;
			if (arg1 != null) {
				XPathNodeIterator it = arg1.EvaluateNodeSet (iter);
				if (it.MoveNext())
					baseUri = it.Current.BaseURI;
				else
					baseUri = VoidBaseUriFlag;
			}

			object o = arg0.Evaluate (iter);
			if (o is XPathNodeIterator)
				return GetDocument ((iter.NamespaceManager as XsltCompiledContext), (XPathNodeIterator)o, baseUri);
			else
				return GetDocument ((iter.NamespaceManager as XsltCompiledContext), o is IFormattable ? ((IFormattable) o).ToString (null, CultureInfo.InvariantCulture) : (o != null ? o.ToString () : null), baseUri);
		}
Beispiel #50
0
 public override string EvaluateString(BaseIterator iter)
 {
     return(this._value);
 }
		public override object Evaluate (BaseIterator iter)
		{
			double d = arg0.EvaluateNumber (iter);
			string s = arg1.EvaluateString (iter);
			QName nm = QName.Empty;
			
			if (arg2 != null)
				nm = XslNameUtil.FromString (arg2.EvaluateString (iter), ctx);
			
			try {
				return ((XsltCompiledContext) iter.NamespaceManager).Processor.CompiledStyle
				.LookupDecimalFormat (nm).FormatNumber (d, s);
			} catch (ArgumentException ex) {
				throw new XsltException (ex.Message, ex, iter.Current);
			}
		}
Beispiel #52
0
 public SimpleSlashIterator(BaseIterator left, NodeSet expr)
     : base(left.NamespaceManager)
 {
     this._left = left;
     this._expr = expr;
 }
		public override object Evaluate (BaseIterator iter)
		{
			XPathNavigator n;
			if (arg0 != null) {
				XPathNodeIterator itr = arg0.EvaluateNodeSet (iter);
				if (itr.MoveNext ())
					n = itr.Current.Clone ();
				else
					return string.Empty; // empty nodeset == empty string
			} else
				n = iter.Current.Clone ();
			
			StringBuilder sb = new StringBuilder ("Mono"); // Ensure begins with alpha
			sb.Append (XmlConvert.EncodeLocalName (n.BaseURI));
			sb.Replace ('_', 'm'); // remove underscores from EncodeLocalName
			sb.Append (n.NodeType);
			sb.Append ('m');

			do {
				sb.Append (IndexInParent (n));
				sb.Append ('m');
			} while (n.MoveToParent ());
			
			return sb.ToString ();
		}
Beispiel #54
0
 public SlashIterator(BaseIterator iter, NodeSet expr) : base(iter.NamespaceManager)
 {
     _iterLeft = iter;
     _expr     = expr;
 }
		public override object Evaluate (BaseIterator iter)
		{
			QName name = XslNameUtil.FromString (arg0.EvaluateString (iter), ctx);
			
			if (name.Namespace == Compiler.XsltNamespace) {
				switch (name.Name) {
					case "version": return "1.0";
					case "vendor": return "Mono";
					case "vendor-url": return "http://www.go-mono.com/";
				}
			}
			
			return "";
		}
Beispiel #56
0
        public override bool MoveNextCore()
        {
            if (_finished)
            {
                return(false);
            }

            if (_iterRight == null)               // First time
            {
                if (!_iterLeft.MoveNext())
                {
                    return(false);
                }
                _iterRight = _expr.EvaluateNodeSet(_iterLeft);
                _iterList  = new SortedList(XPathIteratorComparer.Instance);
            }

            while (true)
            {
                while (!_iterRight.MoveNext())
                {
                    if (_iterList.Count > 0)
                    {
                        int last = _iterList.Count - 1;
                        _iterRight = (BaseIterator)_iterList.GetByIndex(last);
                        _iterList.RemoveAt(last);
                        break;
                    }
                    else if (_nextIterRight != null)
                    {
                        _iterRight     = _nextIterRight;
                        _nextIterRight = null;
                        break;
                    }
                    else if (!_iterLeft.MoveNext())
                    {
                        _finished = true;
                        return(false);
                    }
                    else
                    {
                        _iterRight = _expr.EvaluateNodeSet(_iterLeft);
                    }
                }
                bool loop = true;
                while (loop)
                {
                    loop = false;
                    if (_nextIterRight == null)
                    {
                        bool noMoreNext = false;
                        while (_nextIterRight == null || !_nextIterRight.MoveNext())
                        {
                            if (_iterLeft.MoveNext())
                            {
                                _nextIterRight = _expr.EvaluateNodeSet(_iterLeft);
                            }
                            else
                            {
                                noMoreNext = true;
                                break;
                            }
                        }
                        if (noMoreNext)
                        {
                            _nextIterRight = null;                             // FIXME: More efficient code. Maybe making noMoreNext class scope would be better.
                        }
                    }
                    if (_nextIterRight != null)
                    {
                        switch (_iterRight.Current.ComparePosition(_nextIterRight.Current))
                        {
                        case XmlNodeOrder.After:
                            _iterList [_iterRight] = _iterRight;
                            _iterRight             = _nextIterRight;
                            _nextIterRight         = null;
                            loop = true;
                            break;

                        case XmlNodeOrder.Same:
                            if (!_nextIterRight.MoveNext())
                            {
                                _nextIterRight = null;
                            }

                            else
                            {
                                int last = _iterList.Count;
                                _iterList [_nextIterRight] = _nextIterRight;
                                if (last != _iterList.Count)
                                {
                                    _nextIterRight = (BaseIterator)_iterList.GetByIndex(last);
                                    _iterList.RemoveAt(last);
                                }
                            }

                            loop = true;
                            break;
                        }
                    }
                }
                return(true);
            }
        }
		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);
		}
Beispiel #58
0
		public override object Evaluate (BaseIterator iter)
		{
			return (double) iter.ComparablePosition;
		}
Beispiel #59
0
		public override object Evaluate (BaseIterator iter)
		{
			return v.Evaluate (iter.NamespaceManager as XsltContext);
		}
Beispiel #60
0
 internal BaseIterator(BaseIterator other)
 {
     _nsm     = other._nsm;
     position = other.position;
 }