상속: XMLObjectImpl
예제 #1
0
파일: XMLCtor.cs 프로젝트: hazzik/Rhino.Net
		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);
		}
예제 #2
0
파일: XMLList.cs 프로젝트: hazzik/Rhino.Net
		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;
			}
		}
예제 #3
0
파일: XMLList.cs 프로젝트: hazzik/Rhino.Net
		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;
			}
		}
예제 #4
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		private void AddAttributes(XMLList rv, XML target)
		{
			AddMatchingAttributes(rv, target);
		}
예제 #5
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		internal virtual void AddDescendants(XMLList rv, XML target)
		{
			Rhino.Xmlimpl.XMLName xmlName = this;
			if (xmlName.IsAttributeName())
			{
				MatchDescendantAttributes(rv, target);
			}
			else
			{
				MatchDescendantChildren(rv, target);
			}
		}
예제 #6
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		internal virtual XMLList MatchDescendantChildren(XMLList rv, XML target)
		{
			rv.SetTargets(target, null);
			AddDescendantChildren(rv, target);
			return rv;
		}
예제 #7
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		internal virtual XMLList MatchDescendantAttributes(XMLList rv, XML target)
		{
			rv.SetTargets(target, null);
			AddDescendantAttributes(rv, target);
			return rv;
		}
예제 #8
0
파일: XmlNode.cs 프로젝트: hazzik/Rhino.Net
			internal virtual void Add(XML xml)
			{
				_add(xml.GetAnnotation());
			}
예제 #9
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		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);
					}
				}
			}
		}
예제 #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);
		}
예제 #11
0
파일: XML.cs 프로젝트: hazzik/Rhino.Net
		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();
		}
예제 #12
0
파일: XML.cs 프로젝트: hazzik/Rhino.Net
		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;
		}
예제 #13
0
파일: XML.cs 프로젝트: hazzik/Rhino.Net
		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;
		}
예제 #14
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		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());
				}
			}
		}
예제 #15
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		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]);
				}
			}
		}
예제 #16
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		internal virtual XMLList GetMyValueOn(XML target)
		{
			XMLList rv = target.NewXMLList();
			AddMatches(rv, target);
			return rv;
		}
예제 #17
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		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]);
					}
				}
			}
		}
예제 #18
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		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;
			}
		}
예제 #19
0
파일: XMLName.cs 프로젝트: hazzik/Rhino.Net
		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]);
				}
			}
		}
예제 #20
0
파일: XmlNode.cs 프로젝트: hazzik/Rhino.Net
		internal virtual void SetXml(XML xml)
		{
			this.xml = xml;
		}
예제 #21
0
파일: XMLList.cs 프로젝트: hazzik/Rhino.Net
		private void ReplaceNode(XML xml, XML with)
		{
			xml.ReplaceWith(with);
		}