SaxonC 12.4
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
XdmNode.h
1
2// Copyright (c) 2022 - 2023 Saxonica Limited.
3// This Source Code Form is subject to the terms of the Mozilla Public License,
4// v. 2.0. If a copy of the MPL was not distributed with this file, You can
5// obtain one at http://mozilla.org/MPL/2.0/. This Source Code Form is
6// "Incompatible With Secondary Licenses", as defined by the Mozilla Public
7// License, v. 2.0.
9
10#ifndef SAXON_XDMNODE_h
11#define SAXON_XDMNODE_h
12
13#include "XdmItem.h"
14#include <string.h>
15
16typedef enum eXdmNodeKind {
17 DOCUMENT = 9,
18 ELEMENT = 1,
19 ATTRIBUTE = 2,
20 TEXT = 3,
21 COMMENT = 8,
22 PROCESSING_INSTRUCTION = 7,
23 NAMESPACE = 13,
24 UNKNOWN = 0
25} XDM_NODE_KIND;
26
27enum class EnumXdmAxis {
28 ANCESTOR = 0,
29 ANCESTOR_OR_SELF = 1,
30 ATTRIBUTE = 2,
31 CHILD = 3,
32 DESCENDANT = 4,
33 DESCENDANT_OR_SELF = 5,
34 FOLLOWING = 6,
35 FOLLOWING_SIBLING = 7,
36 NAMESPACE = 8,
37 PARENT = 9,
38 PRECEDING = 10,
39 PRECEDING_SIBLING = 11,
40 SELF = 12
41};
42
43class XdmValue;
44
56class XdmNode : public XdmItem {
57
58public:
61
67 XdmNode(int64_t);
68
71
80 XdmNode(XdmNode *parent, int64_t, XDM_NODE_KIND kind);
81
82 XdmNode(const XdmNode &other);
83
85
88 virtual ~XdmNode();
89
91
97 virtual bool isAtomic();
98
100
104 XdmItem *getHead();
105
107
113 XDM_NODE_KIND getNodeKind();
114
117
123 const char *getNodeName();
124
127
133 const char *getLocalName();
134
136
143
145
151 const char *getBaseUri();
152
155
166 const char *getStringValue();
167
171
196 const char *toString();
197
199
206
209
218 const char *getAttributeValue(const char *name);
219
221
226 int getAttributeCount();
227
229
238 XdmNode **getAttributeNodes(bool cache = false);
239
241
254 XdmNode **axisNodes(EnumXdmAxis axis);
255
256 EnumXdmAxis convertEnumXdmAxis(int n) { return static_cast<EnumXdmAxis>(n); }
257
260 int axisNodeCount();
261
263
268
270
276 bool isNode() { return true; }
277
279
284 XdmNode **getChildren(bool cache = true);
285
287
292 XdmNode *getChild(int i, bool cache = true);
293
295
299 int getChildCount();
300
302
306 XDM_TYPE getType() { return XDM_NODE; }
307
308private:
309 const char *baseURI;
310 const char *nodeName;
311 const char *localName;
312 const char *nodeToString;
313 XdmNode **children;
315 int childCount;
316 int axisCount;
317 XdmNode *parent;
318 XdmValue *typedValue;
320 XdmNode **attrValues;
322 int attrCount;
323 XDM_NODE_KIND nodeKind;
324};
325
326#endif
Definition XdmItem.h:30
virtual int64_t getUnderlyingValue()
Definition XdmItem.cpp:52
Definition XdmNode.h:56
XDM_TYPE getType()
Get the type of the object.
Definition XdmNode.h:306
const char * getStringValue()
Definition XdmNode.cpp:157
int axisNodeCount()
Definition XdmNode.cpp:241
XdmNode * getParent()
Get the parent of this node.
Definition XdmNode.cpp:182
const char * getNodeName()
Definition XdmNode.cpp:114
int64_t getUnderlyingValue()
Get the underlying JNI Java object for the XdmNode.
Definition XdmNode.h:267
const char * toString()
Definition XdmNode.cpp:159
XdmValue * getTypedValue()
Get the typed value of this node, as defined in XDM.
Definition XdmNode.cpp:139
XdmNode * getChild(int i, bool cache=true)
Get the ith child nodes from the current parent node.
Definition XdmNode.cpp:316
int getAttributeCount()
Get the number of attribute node for this current node.
Definition XdmNode.cpp:273
const char * getBaseUri()
Get the base URI of this node.
Definition XdmNode.cpp:172
const char * getLocalName()
Definition XdmNode.cpp:89
XdmItem * getHead()
Get the first item in the sequence.
Definition XdmNode.cpp:155
bool isNode()
Determine whether the item is a node or some other type of item.
Definition XdmNode.h:276
virtual bool isAtomic()
Determine whether the item is an atomic value or some other type of item.
Definition XdmNode.cpp:35
int getChildCount()
Get the count of child nodes from the current node.
Definition XdmNode.cpp:282
XdmNode ** axisNodes(EnumXdmAxis axis)
Get the array of nodes reachable from this node via a given axis.
Definition XdmNode.cpp:243
XDM_NODE_KIND getNodeKind()
Get the kind of node.
Definition XdmNode.cpp:37
XdmNode ** getAttributeNodes(bool cache=false)
Get array of attribute nodes of this element.
Definition XdmNode.cpp:211
XdmNode ** getChildren(bool cache=true)
Get all the child nodes from the current parent node.
Definition XdmNode.cpp:290
virtual ~XdmNode()
Destructor.
Definition XdmNode.cpp:46
const char * getAttributeValue(const char *name)
Definition XdmNode.cpp:198
Definition XdmValue.h:42