Matches() public méthode

public Matches ( XPathExpression expr ) : bool
expr XPathExpression
Résultat bool
Exemple #1
0
	public override string GetNodeXPath (XPathNavigator n)
	{
		if (n.Matches ("/Type/Docs/param")) {
			string type_name = (string) n.Evaluate ("string (ancestor::Type/@FullName)");
			string param_name = (string) n.Evaluate ("string (@name)");
			
			return String.Format ("/Type [@FullName = '{0}']/Docs/param[@name='{1}']", type_name, param_name);
		}

		if (n.Matches ("/Type/Docs/*")) {
			string type_name = (string) n.Evaluate ("string (ancestor::Type/@FullName)");
			
			return String.Format ("/Type [@FullName = '{0}']/Docs/{1}", type_name, n.Name);
		}
		
		if (n.Matches ("/Type/Members/Member/Docs/*")) {
			string type_name = (string) n.Evaluate ("string (ancestor::Type/@FullName)");
			string member_name = (string) n.Evaluate ("string (ancestor::Member/@MemberName)");
			string member_sig = (string) n.Evaluate ("string (ancestor::Member/MemberSignature [@Language='C#']/@Value)");
			string param_name = (string) n.Evaluate ("string (@name)");
			
			if (param_name == null || param_name == "") {
				return String.Format (
				"/Type [@FullName = '{0}']/Members/Member [@MemberName = '{1}'][MemberSignature [@Language='C#']/@Value = '{2}']/Docs/{3}",
				type_name, member_name, member_sig, n.Name);
			} else {
				return String.Format (
				"/Type [@FullName = '{0}']/Members/Member [@MemberName = '{1}'][MemberSignature [@Language='C#']/@Value = '{2}']/Docs/param [@name = '{3}']",
				type_name, member_name, member_sig, param_name);
			}
		}
		
		Message (TraceLevel.Warning, "WARNING: Was not able to get clean XPath expression for node {0}", EditingUtils.GetXPath (n));
		return base.GetNodeXPath (n);
	}
Exemple #2
0
		public bool Matches(XPathExpression xpath, XPathNavigator source)
		{
			xpath = (XPathExpression)xpath.Clone();
			xpath.SetContext(this);
			return source.Matches(xpath);
		}
 public bool Matches(XPathNavigator nav)
 {
     if(Status != XPathSelectorStatus.Compiled)
     {
         Compile(nav);
     }
     if(Status == XPathSelectorStatus.Compiled)
     {
         try
         {
             return nav.Matches(xpath);
         }
         catch
         {
             return false;
         }
     }
     else
     {
         return false;
     }
 }
 /// <summary>
 /// Matches given node against "match" pattern and adds it to 
 /// the index table if the matching succeeded.
 /// </summary>
 /// <param name="node">Node to match</param>
 public void MatchNode(XPathNavigator node)
 {
     foreach (KeyDef keyDef in keys)
     {
         if (node.Matches(keyDef.MatchExpr))
         {
             //Ok, let's calculate key value(s). As per XSLT spec:
             //If the result is a node-set, then for each node in the node-set,
             //the node that matches the pattern has a key of the specified name whose
             //value is the string-value of the node in the node-set; otherwise, the result
             //is converted to a string, and the node that matches the pattern has a
             //key of the specified name with value equal to that string.
             object key = node.Evaluate(keyDef.UseExpr);
             if (key is XPathNodeIterator)
             {
                 XPathNodeIterator ni = (XPathNodeIterator)key;
                 while (ni.MoveNext())
                     AddNodeToIndex(node, ni.Current.Value);
             }
             else
             {
                 AddNodeToIndex(node, key.ToString());
             }
         }
     }
 }
Exemple #5
0
 internal bool Matches(XPathNavigator context, int key) {
     return context.Matches(GetValueQuery(key));
 }
Exemple #6
0
        public bool IsMatch(XPathNavigator xpn, XmlNamespaceManager xnm)
        {
            if ( xpathExpression == null )
            {
                xpathExpression=xpn.Compile(xpath);
                xpathExpression.SetContext(xnm);
            }

            return xpn.Matches(xpathExpression);

            //			Debug.Assert(e.Name.Equals(name), "IsMatch called for incorrect element!");
            //			// TODO: L: bit messy
            //			return Conditions == null || Conditions.Conditions ==null ||
            //				Conditions.Conditions.Count == 0 || Conditions.MatchesAll(e);
        }