summaryrefslogtreecommitdiff
path: root/win32/sablot/include/sxpath.h
blob: d6bd44830a68e1b244c9f96a140af5ecce1f699b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * The Original Code is the Sablotron XSLT Processor.
 *
 * The Initial Developer of the Original Code is Ginger Alliance Ltd.
 * Portions created by Ginger Alliance are Copyright (C) 2000-2002
 * Ginger Alliance Ltd. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the
 * terms of the GNU General Public License Version 2 or later (the
 * "GPL"), in which case the provisions of the GPL are applicable
 * instead of those above.  If you wish to allow use of your
 * version of this file only under the terms of the GPL and not to
 * allow others to use your version of this file under the MPL,
 * indicate your decision by deleting the provisions above and
 * replace them with the notice and other provisions required by
 * the GPL.  If you do not delete the provisions above, a recipient
 * may use your version of this file under either the MPL or the
 * GPL.
 */

#ifndef SXPathHIncl
#define SXPathHIncl

/* basic types needed in sablot.h */
typedef void *SXP_Node;
typedef void *SXP_Document;
typedef void *SXP_NodeList;
typedef SXP_Node NodeHandle;

#include "sablot.h"

typedef enum
{
    ELEMENT_NODE = 1,
    ATTRIBUTE_NODE = 2,
    TEXT_NODE = 3,
    PROCESSING_INSTRUCTION_NODE = 7,
    COMMENT_NODE = 8,
    DOCUMENT_NODE = 9,
    NAMESPACE_NODE = 13
} SXP_NodeType;

typedef enum
{
    SXP_NONE,
    SXP_NUMBER,
    SXP_STRING,
    SXP_BOOLEAN,
    SXP_NODESET
} SXP_ExpressionType;

typedef char SXP_char;

typedef void *QueryContext;

/*option constants */
typedef enum
{
  SXPF_DISPOSE_NAMES = 0x1,
  SXPF_DISPOSE_VALUES = 0x2,
  SXPF_SUPPORTS_UNPARSED_ENTITIES =0x4
} SXPFlags;

/*
 *    DOM handler functions
 *    This handler is registered with the Situation rather than the Processor
 */

/*****************************************************************
DOMHandler

  Handler providing information about a DOM tree to the XPath
  processor
*****************************************************************/

typedef SXP_NodeType     DOMH_getNodeType(SXP_Node n);
typedef const SXP_char*  DOMH_getNodeName(SXP_Node n);
typedef const SXP_char*  DOMH_getNodeNameURI(SXP_Node n);
typedef const SXP_char*  DOMH_getNodeNameLocal(SXP_Node n);
typedef const SXP_char*  DOMH_getNodeValue(SXP_Node n);
typedef SXP_Node         DOMH_getNextSibling(SXP_Node n);
typedef SXP_Node         DOMH_getPreviousSibling(SXP_Node n);
typedef SXP_Node         DOMH_getNextAttrNS(SXP_Node n);
typedef SXP_Node         DOMH_getPreviousAttrNS(SXP_Node n);
typedef int              DOMH_getChildCount(SXP_Node n);
typedef int              DOMH_getAttributeCount(SXP_Node n);
typedef int              DOMH_getNamespaceCount(SXP_Node n);
typedef SXP_Node         DOMH_getChildNo(SXP_Node n, int ndx);
typedef SXP_Node         DOMH_getAttributeNo(SXP_Node n, int ndx);
typedef SXP_Node         DOMH_getNamespaceNo(SXP_Node n, int ndx);
typedef SXP_Node         DOMH_getParent(SXP_Node n);
typedef SXP_Document     DOMH_getOwnerDocument(SXP_Node n);
typedef int              DOMH_compareNodes(SXP_Node n1, SXP_Node n2);
typedef SXP_Document     DOMH_retrieveDocument(const SXP_char* uri,
					       void* udata);
typedef SXP_Node         DOMH_getNodeWithID(SXP_Document doc, const SXP_char* id);
typedef void             DOMH_freeBuffer(SXP_char *buff);

typedef struct
{
    DOMH_getNodeType         *getNodeType;
    DOMH_getNodeName         *getNodeName;
    DOMH_getNodeNameURI      *getNodeNameURI;
    DOMH_getNodeNameLocal    *getNodeNameLocal;
    DOMH_getNodeValue        *getNodeValue;
    DOMH_getNextSibling      *getNextSibling;
    DOMH_getPreviousSibling  *getPreviousSibling;
    DOMH_getNextAttrNS       *getNextAttrNS;
    DOMH_getPreviousAttrNS   *getPreviousAttrNS;
    DOMH_getChildCount       *getChildCount;
    DOMH_getAttributeCount   *getAttributeCount;
    DOMH_getNamespaceCount   *getNamespaceCount;
    DOMH_getChildNo          *getChildNo;
    DOMH_getAttributeNo      *getAttributeNo;
    DOMH_getNamespaceNo      *getNamespaceNo;
    DOMH_getParent           *getParent;
    DOMH_getOwnerDocument    *getOwnerDocument;
    DOMH_compareNodes        *compareNodes;
    DOMH_retrieveDocument    *retrieveDocument;
    DOMH_getNodeWithID       *getNodeWithID;
  /*optional entries - driven by sxpOptions */
    DOMH_freeBuffer          *freeBuffer;
} DOMHandler;

Declare
(
    void SXP_registerDOMHandler(SablotSituation S,
				DOMHandler *domh, void* udata);
)

Declare
(
    void SXP_unregisterDOMHandler(SablotSituation S);
)

/*
 *
 *    QueryContext functions
 *
 */

/*  options setter getter */
Declare
(
    void SXP_setOptions(SablotSituation S, unsigned long options);
)

Declare
(
    void SXP_setMaskBit(SablotSituation S, int mask);
)

Declare
(
    unsigned long SXP_getOptions(SablotSituation S);
)

Declare
(
    int SXP_createQueryContext(SablotSituation S, QueryContext *Q);
)

Declare
(
    int SXP_addVariableBinding(QueryContext Q,
        const SXP_char* name, QueryContext source);
)

Declare
(
    int SXP_addVariableNumber(QueryContext Q,
        const SXP_char* name, double value);
)

Declare
(
    int SXP_addVariableString(QueryContext Q,
        const SXP_char* name, const SXP_char* value);
)

Declare
(
    int SXP_addVariableBoolean(QueryContext Q,
        const SXP_char* name, int value);
)

Declare
(
    int SXP_addNamespaceDeclaration(QueryContext Q,
        const SXP_char* prefix, const SXP_char* uri);
)

Declare
(
    int SXP_query(QueryContext Q, const SXP_char* query,
		  SXP_Node n, int contextPosition, int contextSize);
)

Declare
(
    int SXP_destroyQueryContext(QueryContext Q);
)

/*
 *
 *    Functions to retrieve the query result and its type
 *
 */

Declare
(
    int SXP_getResultType(QueryContext Q, SXP_ExpressionType *type);
)

Declare
(
    int SXP_getResultNumber(QueryContext Q, double *result);
)

Declare
(
    int SXP_getResultBool(QueryContext Q, int *result);
)

Declare
(
    int SXP_getResultString(QueryContext Q, const char **result);
)

Declare
(
    int SXP_getResultNodeset(QueryContext Q, SXP_NodeList *result);
)

/*
 *
 *    NodeList manipulation
 *
 */

Declare
(
    int SXP_getNodeListLength(SXP_NodeList l);
)

Declare
(
    SXP_Node SXP_getNodeListItem(QueryContext Q, SXP_NodeList l, int index);
)


#endif /* SXPathHIncl */