Inheritance: XMLObjectImpl
Esempio n. 1
0
		internal XMLCtor(XML xml, object tag, int id, int arity) : base(xml, tag, id, arity)
		{
			//    private XMLLibImpl lib;
			//        this.lib = xml.lib;
			this.options = xml.GetProcessor();
			ActivatePrototypeMap(MAX_FUNCTION_ID);
		}
Esempio n. 2
0
		internal virtual void Replace(int index, XML xml)
		{
			if (index < Length())
			{
				Rhino.Xmlimpl.XmlNode.InternalList newAnnoList = new Rhino.Xmlimpl.XmlNode.InternalList();
				newAnnoList.Add(_annos, 0, index);
				newAnnoList.Add(xml);
				newAnnoList.Add(_annos, index + 1, Length());
				_annos = newAnnoList;
			}
		}
Esempio n. 3
0
		private void Insert(int index, XML xml)
		{
			if (index < Length())
			{
				Rhino.Xmlimpl.XmlNode.InternalList newAnnoList = new Rhino.Xmlimpl.XmlNode.InternalList();
				newAnnoList.Add(_annos, 0, index);
				newAnnoList.Add(xml);
				newAnnoList.Add(_annos, index, Length());
				_annos = newAnnoList;
			}
		}
Esempio n. 4
0
		private void AddAttributes(XMLList rv, XML target)
		{
			AddMatchingAttributes(rv, target);
		}
Esempio n. 5
0
		internal virtual void AddDescendants(XMLList rv, XML target)
		{
			Rhino.Xmlimpl.XMLName xmlName = this;
			if (xmlName.IsAttributeName())
			{
				MatchDescendantAttributes(rv, target);
			}
			else
			{
				MatchDescendantChildren(rv, target);
			}
		}
Esempio n. 6
0
		internal virtual XMLList MatchDescendantChildren(XMLList rv, XML target)
		{
			rv.SetTargets(target, null);
			AddDescendantChildren(rv, target);
			return rv;
		}
Esempio n. 7
0
		internal virtual XMLList MatchDescendantAttributes(XMLList rv, XML target)
		{
			rv.SetTargets(target, null);
			AddDescendantAttributes(rv, target);
			return rv;
		}
Esempio n. 8
0
			internal virtual void Add(XML xml)
			{
				_add(xml.GetAnnotation());
			}
Esempio n. 9
0
		internal virtual void SetMyValueOn(XML target, object value)
		{
			// Special-case checks for undefined and null
			if (value == null)
			{
				value = "null";
			}
			else
			{
				if (value is Undefined)
				{
					value = "undefined";
				}
			}
			Rhino.Xmlimpl.XMLName xmlName = this;
			// Get the named property
			if (xmlName.IsAttributeName())
			{
				target.SetAttribute(xmlName, value);
			}
			else
			{
				if (xmlName.Uri() == null && xmlName.LocalName().Equals("*"))
				{
					target.SetChildren(value);
				}
				else
				{
					// Convert text into XML if needed.
					XMLObjectImpl xmlValue = null;
					if (value is XMLObjectImpl)
					{
						xmlValue = (XMLObjectImpl)value;
						// Check for attribute type and convert to textNode
						if (xmlValue is XML)
						{
							if (((XML)xmlValue).IsAttribute())
							{
								xmlValue = target.MakeXmlFromString(xmlName, xmlValue.ToString());
							}
						}
						if (xmlValue is XMLList)
						{
							for (int i = 0; i < xmlValue.Length(); i++)
							{
								XML xml = ((XMLList)xmlValue).Item(i);
								if (xml.IsAttribute())
								{
									((XMLList)xmlValue).Replace(i, target.MakeXmlFromString(xmlName, xml.ToString()));
								}
							}
						}
					}
					else
					{
						xmlValue = target.MakeXmlFromString(xmlName, ScriptRuntime.ToString(value));
					}
					XMLList matches = target.GetPropertyList(xmlName);
					if (matches.Length() == 0)
					{
						target.AppendChild(xmlValue);
					}
					else
					{
						// Remove all other matches
						for (int i = 1; i < matches.Length(); i++)
						{
							target.RemoveChild(matches.Item(i).ChildIndex());
						}
						// Replace first match with new value.
						XML firstMatch = matches.Item(0);
						target.Replace(firstMatch.ChildIndex(), xmlValue);
					}
				}
			}
		}
Esempio n. 10
0
		private void ExportToScope(bool @sealed)
		{
			xmlPrototype = NewXML(Rhino.Xmlimpl.XmlNode.CreateText(options, string.Empty));
			xmlListPrototype = NewXMLList();
			namespacePrototype = Namespace.Create(this.globalScope, null, Rhino.Xmlimpl.XmlNode.Namespace.GLOBAL);
			qnamePrototype = QName.Create(this, this.globalScope, null, Rhino.Xmlimpl.XmlNode.QName.Create(Rhino.Xmlimpl.XmlNode.Namespace.Create(string.Empty), string.Empty));
			xmlPrototype.ExportAsJSClass(@sealed);
			xmlListPrototype.ExportAsJSClass(@sealed);
			namespacePrototype.ExportAsJSClass(@sealed);
			qnamePrototype.ExportAsJSClass(@sealed);
		}
Esempio n. 11
0
		private string EcmaToString()
		{
			//    See ECMA357 10.1.1
			if (IsAttribute() || IsText())
			{
				return EcmaValue();
			}
			if (this.HasSimpleContent())
			{
				StringBuilder rv = new StringBuilder();
				for (int i = 0; i < this.node.GetChildCount(); i++)
				{
					Rhino.Xmlimpl.XmlNode child = this.node.GetChild(i);
					if (!child.IsProcessingInstructionType() && !child.IsCommentType())
					{
						// TODO: Probably inefficient; taking clean non-optimized
						// solution for now
						Rhino.Xmlimpl.XML x = new Rhino.Xmlimpl.XML(GetLib(), GetParentScope(), (XMLObject)GetPrototype(), child);
						rv.Append(x.ToString());
					}
				}
				return rv.ToString();
			}
			return ToXMLString();
		}
Esempio n. 12
0
		internal virtual Rhino.Xmlimpl.XML[] GetAttributes()
		{
			Rhino.Xmlimpl.XmlNode[] attributes = this.node.GetAttributes();
			Rhino.Xmlimpl.XML[] rv = new Rhino.Xmlimpl.XML[attributes.Length];
			for (int i = 0; i < rv.Length; i++)
			{
				rv[i] = ToXML(attributes[i]);
			}
			return rv;
		}
Esempio n. 13
0
		internal virtual Rhino.Xmlimpl.XML[] GetChildren()
		{
			if (!IsElement())
			{
				return null;
			}
			Rhino.Xmlimpl.XmlNode[] children = this.node.GetMatchingChildren(Rhino.Xmlimpl.XmlNode.Filter.TRUE);
			Rhino.Xmlimpl.XML[] rv = new Rhino.Xmlimpl.XML[children.Length];
			for (int i = 0; i < rv.Length; i++)
			{
				rv[i] = ToXML(children[i]);
			}
			return rv;
		}
Esempio n. 14
0
		internal virtual void AddMatches(XMLList rv, XML target)
		{
			if (IsDescendants())
			{
				AddDescendants(rv, target);
			}
			else
			{
				if (IsAttributeName())
				{
					AddAttributes(rv, target);
				}
				else
				{
					XML[] children = target.GetChildren();
					if (children != null)
					{
						for (int i = 0; i < children.Length; i++)
						{
							if (this.Matches(children[i]))
							{
								rv.AddToList(children[i]);
							}
						}
					}
					rv.SetTargets(target, this.ToQname());
				}
			}
		}
Esempio n. 15
0
		private void AddDescendantChildren(XMLList list, XML target)
		{
			Rhino.Xmlimpl.XMLName xmlName = this;
			if (target.IsElement())
			{
				XML[] children = target.GetChildren();
				for (int i = 0; i < children.Length; i++)
				{
					if (xmlName.Matches(children[i]))
					{
						list.AddToList(children[i]);
					}
					AddDescendantChildren(list, children[i]);
				}
			}
		}
Esempio n. 16
0
		internal virtual XMLList GetMyValueOn(XML target)
		{
			XMLList rv = target.NewXMLList();
			AddMatches(rv, target);
			return rv;
		}
Esempio n. 17
0
		internal virtual void AddMatchingAttributes(XMLList list, XML target)
		{
			Rhino.Xmlimpl.XMLName name = this;
			if (target.IsElement())
			{
				XML[] attributes = target.GetAttributes();
				for (int i = 0; i < attributes.Length; i++)
				{
					if (name.Matches(attributes[i]))
					{
						list.AddToList(attributes[i]);
					}
				}
			}
		}
Esempio n. 18
0
		internal bool Matches(XML node)
		{
			Rhino.Xmlimpl.XmlNode.QName qname = node.GetNodeQname();
			string nodeUri = null;
			if (qname.GetNamespace() != null)
			{
				nodeUri = qname.GetNamespace().GetUri();
			}
			if (isAttributeName)
			{
				if (node.IsAttribute())
				{
					if (this.Uri() == null || this.Uri().Equals(nodeUri))
					{
						if (this.LocalName().Equals("*") || this.LocalName().Equals(qname.GetLocalName()))
						{
							return true;
						}
					}
					return false;
				}
				else
				{
					//    TODO    Could throw exception maybe, should not call this method on attribute name with arbitrary node type
					//            unless we traverse all attributes and children habitually
					return false;
				}
			}
			else
			{
				if (this.Uri() == null || ((node.IsElement()) && this.Uri().Equals(nodeUri)))
				{
					if (LocalName().Equals("*"))
					{
						return true;
					}
					if (node.IsElement())
					{
						if (LocalName().Equals(qname.GetLocalName()))
						{
							return true;
						}
					}
				}
				return false;
			}
		}
Esempio n. 19
0
		private void AddDescendantAttributes(XMLList list, XML target)
		{
			if (target.IsElement())
			{
				AddMatchingAttributes(list, target);
				XML[] children = target.GetChildren();
				for (int i = 0; i < children.Length; i++)
				{
					AddDescendantAttributes(list, children[i]);
				}
			}
		}
Esempio n. 20
0
		internal virtual void SetXml(XML xml)
		{
			this.xml = xml;
		}
Esempio n. 21
0
		private void ReplaceNode(XML xml, XML with)
		{
			xml.ReplaceWith(with);
		}