FBXPath-Private.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import <WebDriverAgentLib/FBXPath.h>
  10. NS_ASSUME_NONNULL_BEGIN
  11. @interface FBXPath ()
  12. /**
  13. Gets xmllib2-compatible XML representation of n XCElementSnapshot instance
  14. @param root the root element to execute XPath query for
  15. @param writer the correspondig libxml2 writer object
  16. @param elementStore an empty dictionary to store indexes mapping or nil if no mappings should be stored
  17. @param query Optional XPath query value. By analyzing this query we may optimize the lookup speed.
  18. @param excludedAttributes The list of XML attribute names to be excluded from the generated XML representation.
  19. Setting nil to this argument means that none of the known attributes must be excluded.
  20. If `query` argument is assigned then `excludedAttributes` argument is effectively ignored.
  21. @return zero if the method has completed successfully
  22. */
  23. + (int)xmlRepresentationWithRootElement:(id<FBXCElementSnapshot>)root
  24. writer:(xmlTextWriterPtr)writer
  25. elementStore:(nullable NSMutableDictionary *)elementStore
  26. query:(nullable NSString*)query
  27. excludingAttributes:(nullable NSArray<NSString *> *)excludedAttributes;
  28. /**
  29. Gets the list of matched snapshots from xmllib2-compatible xmlNodeSetPtr structure
  30. @param nodeSet set of nodes returned after successful XPath evaluation
  31. @param elementStore dictionary containing index->snapshot mapping
  32. @return array of filtered elements or nil in case of failure. Can be empty array as well
  33. */
  34. + (NSArray *)collectMatchingSnapshots:(xmlNodeSetPtr)nodeSet elementStore:(NSMutableDictionary *)elementStore;
  35. /**
  36. Gets the list of matched XPath nodes from xmllib2-compatible XML document
  37. @param xpathQuery actual query. Should be valid XPath 1.0-compatible expression
  38. @param document libxml2-compatible document pointer
  39. @param contextNode Optonal context node instance
  40. @return pointer to a libxml2-compatible structure with set of matched nodes or NULL in case of failure
  41. */
  42. + (xmlXPathObjectPtr)evaluate:(NSString *)xpathQuery
  43. document:(xmlDocPtr)doc
  44. contextNode:(nullable xmlNodePtr)contextNode;
  45. @end
  46. NS_ASSUME_NONNULL_END