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