Exemplo n.º 1
0
		private static Rhino.Xmlimpl.XmlNode CreateImpl(System.Xml.XmlNode node)
		{
			if (node is XmlDocument)
			{
				throw new ArgumentException();
			}
			Rhino.Xmlimpl.XmlNode rv = null;
			if (GetUserData(node) == null)
			{
				rv = new Rhino.Xmlimpl.XmlNode();
				rv.dom = node;
				SetUserData(node, rv);
			}
			else
			{
				rv = GetUserData(node);
			}
			return rv;
		}
Exemplo n.º 2
0
		internal virtual Rhino.Xmlimpl.XmlNode[] GetAttributes()
		{
			XmlNamedNodeMap attrs = this.dom.Attributes;
			//    TODO    Or could make callers handle null?
			if (attrs == null)
			{
				throw new InvalidOperationException("Must be element.");
			}
			Rhino.Xmlimpl.XmlNode[] rv = new Rhino.Xmlimpl.XmlNode[attrs.Count];
			for (int i = 0; i < attrs.Count; i++)
			{
				rv[i] = CreateImpl(attrs.Item(i));
			}
			return rv;
		}
Exemplo n.º 3
0
		//
		//    Methods relating to modification of child nodes
		//
		//    We create all the nodes we are inserting before doing the insert to
		//    avoid nasty cycles caused by mutability of these objects.  For example,
		//    what if the toString() method of value modifies the XML object we were
		//    going to insert into?  insertAfter might get confused about where to
		//    insert.  This actually came up with SpiderMonkey, leading to a (very)
		//    long discussion.  See bug #354145.
		private Rhino.Xmlimpl.XmlNode[] GetNodesForInsert(object value)
		{
			if (value is Rhino.Xmlimpl.XML)
			{
				return new Rhino.Xmlimpl.XmlNode[] { ((Rhino.Xmlimpl.XML)value).node };
			}
			else
			{
				if (value is XMLList)
				{
					XMLList list = (XMLList)value;
					Rhino.Xmlimpl.XmlNode[] rv = new Rhino.Xmlimpl.XmlNode[list.Length()];
					for (int i = 0; i < list.Length(); i++)
					{
						rv[i] = list.Item(i).node;
					}
					return rv;
				}
				else
				{
					return new Rhino.Xmlimpl.XmlNode[] { Rhino.Xmlimpl.XmlNode.CreateText(GetProcessor(), ScriptRuntime.ToString(value)) };
				}
			}
		}
Exemplo n.º 4
0
		internal virtual void Initialize(Rhino.Xmlimpl.XmlNode node)
		{
			this.node = node;
			this.node.SetXml(this);
		}