IdPattern.cs 808 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // Mono.Xml.XPath.IdPattern
  3. //
  4. // Author:
  5. // Ben Maurer ([email protected])
  6. //
  7. // (C) 2003 Ben Maurer
  8. //
  9. using System;
  10. using System.Collections;
  11. using System.IO;
  12. using System.Xml;
  13. using System.Xml.Schema;
  14. using System.Xml.XPath;
  15. using System.Xml.Xsl;
  16. namespace Mono.Xml.XPath {
  17. internal class IdPattern : LocationPathPattern {
  18. string [] ids;
  19. public IdPattern (string arg0)
  20. : base ((NodeTest) null)
  21. {
  22. ids = arg0.Split (XmlChar.WhitespaceChars);
  23. }
  24. public override bool Matches (XPathNavigator node, XsltContext ctx)
  25. {
  26. XPathNavigator tmp = node.Clone ();
  27. for (int i = 0; i < ids.Length; i++)
  28. if (tmp.MoveToId (ids [i]) && tmp.IsSamePosition (node))
  29. return true;
  30. return false;
  31. }
  32. public override double DefaultPriority { get { return 0.5; } }
  33. }
  34. }