pattern.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Summary: pattern expression handling
  3. * Description: allows to compile and test pattern expressions for nodes
  4. * either in a tree or based on a parser state.
  5. *
  6. * Copy: See Copyright for the status of this software.
  7. *
  8. * Author: Daniel Veillard
  9. */
  10. #ifndef __XML_PATTERN_H__
  11. #define __XML_PATTERN_H__
  12. #include <libxml/xmlversion.h>
  13. #include <libxml/tree.h>
  14. #include <libxml/dict.h>
  15. #ifdef LIBXML_PATTERN_ENABLED
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * xmlPattern:
  21. *
  22. * A compiled (XPath based) pattern to select nodes
  23. */
  24. typedef struct _xmlPattern xmlPattern;
  25. typedef xmlPattern *xmlPatternPtr;
  26. /**
  27. * xmlPatternFlags:
  28. *
  29. * This is the set of options affecting the behaviour of pattern
  30. * matching with this module
  31. *
  32. */
  33. typedef enum {
  34. XML_PATTERN_DEFAULT = 0, /* simple pattern match */
  35. XML_PATTERN_XPATH = 1<<0, /* standard XPath pattern */
  36. XML_PATTERN_XSSEL = 1<<1, /* XPath subset for schema selector */
  37. XML_PATTERN_XSFIELD = 1<<2 /* XPath subset for schema field */
  38. } xmlPatternFlags;
  39. XMLPUBFUN void
  40. xmlFreePattern (xmlPatternPtr comp);
  41. XMLPUBFUN void
  42. xmlFreePatternList (xmlPatternPtr comp);
  43. XMLPUBFUN xmlPatternPtr
  44. xmlPatterncompile (const xmlChar *pattern,
  45. xmlDict *dict,
  46. int flags,
  47. const xmlChar **namespaces);
  48. XMLPUBFUN int
  49. xmlPatternCompileSafe (const xmlChar *pattern,
  50. xmlDict *dict,
  51. int flags,
  52. const xmlChar **namespaces,
  53. xmlPatternPtr *patternOut);
  54. XMLPUBFUN int
  55. xmlPatternMatch (xmlPatternPtr comp,
  56. xmlNodePtr node);
  57. /* streaming interfaces */
  58. typedef struct _xmlStreamCtxt xmlStreamCtxt;
  59. typedef xmlStreamCtxt *xmlStreamCtxtPtr;
  60. XMLPUBFUN int
  61. xmlPatternStreamable (xmlPatternPtr comp);
  62. XMLPUBFUN int
  63. xmlPatternMaxDepth (xmlPatternPtr comp);
  64. XMLPUBFUN int
  65. xmlPatternMinDepth (xmlPatternPtr comp);
  66. XMLPUBFUN int
  67. xmlPatternFromRoot (xmlPatternPtr comp);
  68. XMLPUBFUN xmlStreamCtxtPtr
  69. xmlPatternGetStreamCtxt (xmlPatternPtr comp);
  70. XMLPUBFUN void
  71. xmlFreeStreamCtxt (xmlStreamCtxtPtr stream);
  72. XMLPUBFUN int
  73. xmlStreamPushNode (xmlStreamCtxtPtr stream,
  74. const xmlChar *name,
  75. const xmlChar *ns,
  76. int nodeType);
  77. XMLPUBFUN int
  78. xmlStreamPush (xmlStreamCtxtPtr stream,
  79. const xmlChar *name,
  80. const xmlChar *ns);
  81. XMLPUBFUN int
  82. xmlStreamPushAttr (xmlStreamCtxtPtr stream,
  83. const xmlChar *name,
  84. const xmlChar *ns);
  85. XMLPUBFUN int
  86. xmlStreamPop (xmlStreamCtxtPtr stream);
  87. XMLPUBFUN int
  88. xmlStreamWantsAnyNode (xmlStreamCtxtPtr stream);
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92. #endif /* LIBXML_PATTERN_ENABLED */
  93. #endif /* __XML_PATTERN_H__ */