1 /* libxml2 - Library for parsing XML documents 2 * Copyright (C) 2006-2019 Free Software Foundation, Inc. 3 * 4 * This file is not part of the GNU gettext program, but is used with 5 * GNU gettext. 6 * 7 * The original copyright notice is as follows: 8 */ 9 10 /* 11 * Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved. 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining a copy 14 * of this software and associated documentation files (the "Software"), to deal 15 * in the Software without restriction, including without limitation the rights 16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 * copies of the Software, and to permit persons to whom the Software is fur- 18 * nished to do so, subject to the following conditions: 19 * 20 * The above copyright notice and this permission notice shall be included in 21 * all copies or substantial portions of the Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- 25 * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 * THE SOFTWARE. 30 * 31 * Author: Daniel Veillard 32 */ 33 34 /* 35 * Summary: pattern expression handling 36 * Description: allows to compile and test pattern expressions for nodes 37 * either in a tree or based on a parser state. 38 */ 39 40 #ifndef __XML_PATTERN_H__ 41 #define __XML_PATTERN_H__ 42 43 #include <libxml/xmlversion.h> 44 #include <libxml/tree.h> 45 #include <libxml/dict.h> 46 47 #ifdef LIBXML_PATTERN_ENABLED 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 /** 54 * xmlPattern: 55 * 56 * A compiled (XPath based) pattern to select nodes 57 */ 58 typedef struct _xmlPattern xmlPattern; 59 typedef xmlPattern *xmlPatternPtr; 60 61 /** 62 * xmlPatternFlags: 63 * 64 * This is the set of options affecting the behaviour of pattern 65 * matching with this module 66 * 67 */ 68 typedef enum { 69 XML_PATTERN_DEFAULT = 0, /* simple pattern match */ 70 XML_PATTERN_XPATH = 1<<0, /* standard XPath pattern */ 71 XML_PATTERN_XSSEL = 1<<1, /* XPath subset for schema selector */ 72 XML_PATTERN_XSFIELD = 1<<2 /* XPath subset for schema field */ 73 } xmlPatternFlags; 74 75 XMLPUBFUN void XMLCALL 76 xmlFreePattern (xmlPatternPtr comp); 77 78 XMLPUBFUN void XMLCALL 79 xmlFreePatternList (xmlPatternPtr comp); 80 81 XMLPUBFUN xmlPatternPtr XMLCALL 82 xmlPatterncompile (const xmlChar *pattern, 83 xmlDict *dict, 84 int flags, 85 const xmlChar **namespaces); 86 XMLPUBFUN int XMLCALL 87 xmlPatternMatch (xmlPatternPtr comp, 88 xmlNodePtr node); 89 90 /* streaming interfaces */ 91 typedef struct _xmlStreamCtxt xmlStreamCtxt; 92 typedef xmlStreamCtxt *xmlStreamCtxtPtr; 93 94 XMLPUBFUN int XMLCALL 95 xmlPatternStreamable (xmlPatternPtr comp); 96 XMLPUBFUN int XMLCALL 97 xmlPatternMaxDepth (xmlPatternPtr comp); 98 XMLPUBFUN int XMLCALL 99 xmlPatternMinDepth (xmlPatternPtr comp); 100 XMLPUBFUN int XMLCALL 101 xmlPatternFromRoot (xmlPatternPtr comp); 102 XMLPUBFUN xmlStreamCtxtPtr XMLCALL 103 xmlPatternGetStreamCtxt (xmlPatternPtr comp); 104 XMLPUBFUN void XMLCALL 105 xmlFreeStreamCtxt (xmlStreamCtxtPtr stream); 106 XMLPUBFUN int XMLCALL 107 xmlStreamPushNode (xmlStreamCtxtPtr stream, 108 const xmlChar *name, 109 const xmlChar *ns, 110 int nodeType); 111 XMLPUBFUN int XMLCALL 112 xmlStreamPush (xmlStreamCtxtPtr stream, 113 const xmlChar *name, 114 const xmlChar *ns); 115 XMLPUBFUN int XMLCALL 116 xmlStreamPushAttr (xmlStreamCtxtPtr stream, 117 const xmlChar *name, 118 const xmlChar *ns); 119 XMLPUBFUN int XMLCALL 120 xmlStreamPop (xmlStreamCtxtPtr stream); 121 XMLPUBFUN int XMLCALL 122 xmlStreamWantsAnyNode (xmlStreamCtxtPtr stream); 123 #ifdef __cplusplus 124 } 125 #endif 126 127 #endif /* LIBXML_PATTERN_ENABLED */ 128 129 #endif /* __XML_PATTERN_H__ */ 130