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); } }
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; }
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 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; }
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; }