internal virtual Rhino.Xmlimpl.XML MakeXmlFromString(XMLName name, string value) { try { return NewTextElementXML(this.node, name.ToQname(), value); } catch (Exception e) { throw ScriptRuntime.TypeError(e.Message); } }
// // Methods from XMLObjectImpl // internal override bool HasXMLProperty(XMLName xmlName) { return (GetPropertyList(xmlName).Length() > 0); }
internal abstract bool HasOwnProperty(XMLName xmlName);
internal abstract XMLList Child(XMLName xmlName);
internal abstract void AddMatches(XMLList rv, XMLName name);
/// <summary> /// ecmaPut(cx, id, value) calls this after resolving when id to XMLName /// and checking it is not Uint32 index. /// </summary> /// <remarks> /// ecmaPut(cx, id, value) calls this after resolving when id to XMLName /// and checking it is not Uint32 index. /// </remarks> internal abstract void PutXMLProperty(XMLName name, object value);
/// <summary> /// ecmaHas(cx, id) calls this after resolving when id to XMLName /// and checking it is not Uint32 index. /// </summary> /// <remarks> /// ecmaHas(cx, id) calls this after resolving when id to XMLName /// and checking it is not Uint32 index. /// </remarks> internal abstract bool HasXMLProperty(XMLName name);
internal static Rhino.Xmlimpl.XmlNode.Filter PROCESSING_INSTRUCTION(XMLName name) { return new _Filter_852(name); }
internal override void AddMatches(XMLList rv, XMLName name) { name.AddMatches(rv, this); }
internal virtual void SetAttribute(XMLName xmlName, object value) { if (!IsElement()) { throw new InvalidOperationException("Can only set attributes on elements."); } // TODO Is this legal, but just not "supported"? If so, support it. if (xmlName.Uri() == null && xmlName.LocalName().Equals("*")) { throw ScriptRuntime.TypeError("@* assignment not supported."); } this.node.SetAttribute(xmlName.ToQname(), ScriptRuntime.ToString(value)); }
internal override bool HasOwnProperty(XMLName xmlName) { bool hasProperty = false; if (IsPrototype()) { string property = xmlName.LocalName(); hasProperty = (0 != FindPrototypeId(property)); } else { hasProperty = (GetPropertyList(xmlName).Length() > 0); } return hasProperty; }
internal override void PutXMLProperty(XMLName xmlName, object value) { if (IsPrototype()) { } else { // TODO Is this really a no-op? Check the spec to be sure xmlName.SetMyValueOn(this, value); } }
internal override void DeleteXMLProperty(XMLName name) { XMLList list = GetPropertyList(name); for (int i = 0; i < list.Length(); i++) { list.Item(i).node.DeleteMe(); } }
// Used only by XML, XMLList internal virtual XMLList GetPropertyList(XMLName name) { return name.GetMyValueOn(this); }
internal override object GetXMLProperty(XMLName xmlName) { return GetPropertyList(xmlName); }
internal static Rhino.Xmlimpl.XMLName FormProperty(Rhino.Xmlimpl.XmlNode.Namespace @namespace, string localName) { if (localName != null && localName.Equals("*")) { localName = null; } Rhino.Xmlimpl.XMLName rv = new Rhino.Xmlimpl.XMLName(); rv.qname = Rhino.Xmlimpl.XmlNode.QName.Create(@namespace, localName); return rv; }
internal static Rhino.Xmlimpl.XMLName Create(Rhino.Xmlimpl.XmlNode.QName qname, bool attribute, bool descendants) { Rhino.Xmlimpl.XMLName rv = new Rhino.Xmlimpl.XMLName(); rv.qname = qname; rv.isAttributeName = attribute; rv.isDescendants = descendants; return rv; }
internal override XMLList Elements(XMLName name) { XMLList rv = NewXMLList(); rv.SetTargets(this, name.ToQname()); // TODO Should have an XMLNode.Filter implementation based on XMLName Rhino.Xmlimpl.XmlNode[] elements = this.node.GetMatchingChildren(Rhino.Xmlimpl.XmlNode.Filter.ELEMENT); for (int i = 0; i < elements.Length; i++) { if (name.Matches(ToXML(elements[i]))) { rv.AddToList(ToXML(elements[i])); } } return rv; }
public _Filter_852(XMLName name) { this.name = name; }
internal override XMLList Child(XMLName xmlName) { // TODO Right now I think this method would allow child( "@xxx" ) to return the xxx attribute, which is wrong XMLList rv = NewXMLList(); // TODO Should this also match processing instructions? If so, we have to change the filter and also the XMLName // class to add an acceptsProcessingInstruction() method Rhino.Xmlimpl.XmlNode[] elements = this.node.GetMatchingChildren(Rhino.Xmlimpl.XmlNode.Filter.ELEMENT); for (int i = 0; i < elements.Length; i++) { if (xmlName.MatchesElement(elements[i].GetQname())) { rv.AddToList(ToXML(elements[i])); } } rv.SetTargets(this, xmlName.ToQname()); return rv; }
/// <summary> /// ecmaGet(cx, id) calls this after resolving when id to XMLName /// and checking it is not Uint32 index. /// </summary> /// <remarks> /// ecmaGet(cx, id) calls this after resolving when id to XMLName /// and checking it is not Uint32 index. /// </remarks> internal abstract object GetXMLProperty(XMLName name);
internal virtual Rhino.Xmlimpl.XML Replace(XMLName xmlName, object xml) { PutXMLProperty(xmlName, xml); return this; }
/// <summary> /// ecmaDelete(cx, id) calls this after resolving when id to XMLName /// and checking it is not Uint32 index. /// </summary> /// <remarks> /// ecmaDelete(cx, id) calls this after resolving when id to XMLName /// and checking it is not Uint32 index. /// </remarks> internal abstract void DeleteXMLProperty(XMLName name);
internal override XMLList ProcessingInstructions(XMLName xmlName) { XMLList rv = NewXMLList(); this.node.AddMatchingChildren(rv, Rhino.Xmlimpl.XmlNode.Filter.PROCESSING_INSTRUCTION(xmlName)); return rv; }
private XMLList GetMatches(XMLName name) { XMLList rv = NewXMLList(); AddMatches(rv, name); return rv; }
private Ref XmlPrimaryReference(Context cx, XMLName xmlName, Scriptable scope) { XMLObjectImpl xmlObj; XMLObjectImpl firstXml = null; for (; ; ) { // XML object can only present on scope chain as a wrapper // of XMLWithScope if (scope is XMLWithScope) { xmlObj = (XMLObjectImpl)scope.GetPrototype(); if (xmlObj.HasXMLProperty(xmlName)) { break; } if (firstXml == null) { firstXml = xmlObj; } } scope = scope.GetParentScope(); if (scope == null) { xmlObj = firstXml; break; } } // xmlObj == null corresponds to undefined as the target of // the reference if (xmlObj != null) { xmlName.InitXMLObject(xmlObj); } return xmlName; }
internal abstract XMLList Elements(XMLName xmlName);
internal static Rhino.Xmlimpl.XMLName FormStar() { Rhino.Xmlimpl.XMLName rv = new Rhino.Xmlimpl.XMLName(); rv.qname = Rhino.Xmlimpl.XmlNode.QName.Create(null, null); return rv; }
internal abstract XMLList ProcessingInstructions(XMLName xmlName);
private Rhino.Xmlimpl.XMLList GetPropertyList(XMLName name) { Rhino.Xmlimpl.XMLList propertyList = NewXMLList(); Rhino.Xmlimpl.XmlNode.QName qname = null; if (!name.IsDescendants() && !name.IsAttributeName()) { // Only set the targetProperty if this is a regular child get // and not a descendant or attribute get qname = name.ToQname(); } propertyList.SetTargets(this, qname); for (int i = 0; i < Length(); i++) { propertyList.AddToList(GetXmlFromAnnotation(i).GetPropertyList(name)); } return propertyList; }