2 * Copyright (c) 2016, Masatake YAMATO
3 * Copyright (c) 2016, Red Hat, Inc.
5 * This source code is released for free distribution under the terms of the
6 * GNU General Public License version 2 or (at your option) any later version.
8 * Xpath based parer API
10 #ifndef CTAGS_LXPATH_PARSE_H
11 #define CTAGS_LXPATH_PARSE_H
17 #include "general.h" /* must always come first */
21 #include <libxml/xpath.h>
22 #include <libxml/tree.h>
25 #define xmlXPathCompExpr void
26 #define xmlXPathContext void
34 typedef struct sTagXpathMakeTagSpec
{
35 /* Kind used in making a tag.
36 If kind is KIND_GHOST_INDEX, a function
37 specified with decideKind is called to decide
38 the kind for the tag. */
41 /* If make is NULL, just makeTagEntry is used instead. */
42 void (*make
) (xmlNode
*node
,
44 const struct sTagXpathMakeTagSpec
*spec
,
47 int (*decideKind
) (xmlNode
*node
,
49 const struct sTagXpathMakeTagSpec
*spec
,
51 /* TODO: decideRole */
52 } tagXpathMakeTagSpec
;
54 typedef struct sTagXpathRecurSpec
{
55 void (*enter
) (xmlNode
*node
,
57 const struct sTagXpathRecurSpec
*spec
,
61 int nextTable
; /* A parser can use this field any purpose.
62 main/lxpath part doesn't touch this. */
66 typedef struct sTagXpathTable
68 const char *const xpath
;
69 enum { LXPATH_TABLE_DO_MAKE
, LXPATH_TABLE_DO_RECUR
} specType
;
71 tagXpathMakeTagSpec makeTagSpec
;
72 tagXpathRecurSpec recurSpec
;
74 xmlXPathCompExpr
* xpathCompiled
;
77 typedef struct sTagXpathTableTable
{
82 typedef struct sXpathFileSpec
{
84 NULL represents the associated field in DTD is not examined.
85 "" (an empty string) represents the associated field in DTD
86 (and root element) must not exist. */
87 const char *rootElementName
;
88 const char *nameInDTD
;
89 const char *externalID
;
91 const char *rootNSPrefix
;
92 const char *rootNSHref
;
100 /* Xpath interface */
101 extern void findXMLTagsFull (xmlXPathContext
*ctx
, xmlNode
*root
,
103 void (* runAfter
) (xmlXPathContext
*, xmlNode
*, void *),
106 extern void findXMLTags (xmlXPathContext
*ctx
, xmlNode
*root
,
110 extern void updateXMLTagLine (tagEntryInfo
*e
, xmlNode
*node
);
112 #endif /* CTAGS_LXPATH_PARSE_H */