Rhino.Xmlimpl.XMLName.Matches C# (CSharp) Method

Matches() private method

private Matches ( XML node ) : bool
node XML
return bool
		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;
			}
		}

Usage Example

Example #1
0
		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;
		}