SaxonC 12.5
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
87 XdmNode(const XdmNode &other);
88
90
93 virtual ~XdmNode();
94
96
102 virtual bool isAtomic();
103
105
109 XdmItem *getHead();
110
112
118 XDM_NODE_KIND getNodeKind();
119
122
128 const char *getNodeName();
129
132
138 const char *getLocalName();
139
141
148
149
151
155 int getLineNumber();
156
157
158
160
164 int getColumnNumber();
165
167
173 const char *getBaseUri();
174
177
188 const char *getStringValue();
189
193
218 const char *toString();
219
221
228
231
240 const char *getAttributeValue(const char *name);
241
243
248 int getAttributeCount();
249
251
260 XdmNode **getAttributeNodes(bool cache = false);
261
263
276 XdmNode **axisNodes(EnumXdmAxis axis);
277
283 EnumXdmAxis convertEnumXdmAxis(int n) { return static_cast<EnumXdmAxis>(n); }
284
287 int axisNodeCount();
288
290
295
297
303 bool isNode() { return true; }
304
306
310 XdmNode **getChildren(bool cache = false);
311
313
318 XdmNode *getChild(int i, bool cache = false);
319
321
325 int getChildCount();
326
328
332 XDM_TYPE getType() { return XDM_NODE; }
333
334
339
344
350
353
356 static void deleteChildrenArray(XdmNode **fetchedChildren) {
357 if (fetchedChildren != nullptr) {
358 delete[] fetchedChildren;
359 fetchedChildren = nullptr;
360 }
361 }
362
363
364private:
365 const char *baseURI;
366 const char *nodeName;
367 const char *localName;
368 const char *nodeToString;
369 XdmNode **children;
371 int childCount;
372 int axisCount;
373 XdmNode *parent;
374 XdmValue *typedValue;
376 XdmNode **attrValues;
378 int attrCount;
379 XDM_NODE_KIND nodeKind;
380};
381
382#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:332
const char * getStringValue()
Definition XdmNode.cpp:205
int axisNodeCount()
Definition XdmNode.cpp:289
XdmNode * getParent()
Get the parent of this node.
Definition XdmNode.cpp:230
const char * getNodeName()
Definition XdmNode.cpp:154
int64_t getUnderlyingValue()
Get the underlying JNI Java object for the XdmNode.
Definition XdmNode.h:294
const char * toString()
Definition XdmNode.cpp:207
XdmValue * getTypedValue()
Get the typed value of this node, as defined in XDM.
Definition XdmNode.cpp:179
void incrementRefCountForRelinquishedChildren()
Definition XdmNode.cpp:96
int getAttributeCount()
Get the number of attribute node for this current node.
Definition XdmNode.cpp:321
const char * getBaseUri()
Get the base URI of this node.
Definition XdmNode.cpp:220
XdmNode ** getChildren(bool cache=false)
Get all the child nodes from the current parent node.
Definition XdmNode.cpp:338
const char * getLocalName()
Definition XdmNode.cpp:129
XdmNode(int64_t)
Definition XdmNode.cpp:9
XdmItem * getHead()
Get the first item in the sequence.
Definition XdmNode.cpp:203
bool isNode()
Determine whether the item is a node or some other type of item.
Definition XdmNode.h:303
int getColumnNumber()
Get the column number of the node in a source document.
Definition XdmNode.cpp:199
virtual bool isAtomic()
Determine whether the item is an atomic value or some other type of item.
Definition XdmNode.cpp:38
int getChildCount()
Get the count of child nodes from the current node.
Definition XdmNode.cpp:330
XdmNode * getChild(int i, bool cache=false)
Get the ith child nodes from the current parent node.
Definition XdmNode.cpp:364
int getLineNumber()
Get the line number of the node in a source document.
Definition XdmNode.cpp:195
XdmNode ** axisNodes(EnumXdmAxis axis)
Get the array of nodes reachable from this node via a given axis.
Definition XdmNode.cpp:291
static void deleteChildrenArray(XdmNode **fetchedChildren)
Definition XdmNode.h:356
bool hasRelinquishedChildren()
Definition XdmNode.cpp:109
EnumXdmAxis convertEnumXdmAxis(int n)
Definition XdmNode.h:283
void resetRelinquishedChildren()
Definition XdmNode.cpp:113
XDM_NODE_KIND getNodeKind()
Get the kind of node.
Definition XdmNode.cpp:40
XdmNode ** getAttributeNodes(bool cache=false)
Get array of attribute nodes of this element.
Definition XdmNode.cpp:259
virtual ~XdmNode()
Destructor.
Definition XdmNode.cpp:49
const char * getAttributeValue(const char *name)
Definition XdmNode.cpp:246
Definition XdmValue.h:42