SaxonC 12.7.0
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 "saxonc_export.h"
14#include "saxonc/XdmItem.h"
15#include <string.h>
16
17typedef enum eXdmNodeKind {
18 DOCUMENT = 9,
19 ELEMENT = 1,
20 ATTRIBUTE = 2,
21 TEXT = 3,
22 COMMENT = 8,
23 PROCESSING_INSTRUCTION = 7,
24 NAMESPACE = 13,
25 UNKNOWN = 0
26} XDM_NODE_KIND;
27
28enum class SAXONC_EXPORT EnumXdmAxis {
29 ANCESTOR = 0,
30 ANCESTOR_OR_SELF = 1,
31 ATTRIBUTE = 2,
32 CHILD = 3,
33 DESCENDANT = 4,
34 DESCENDANT_OR_SELF = 5,
35 FOLLOWING = 6,
36 FOLLOWING_SIBLING = 7,
37 NAMESPACE = 8,
38 PARENT = 9,
39 PRECEDING = 10,
40 PRECEDING_SIBLING = 11,
41 SELF = 12
42};
43
44class XdmValue;
45
57class SAXONC_EXPORT XdmNode : public XdmItem {
58
59public:
64 XdmNode(int64_t objRef);
65
73 XdmNode(XdmNode *parent, int64_t objRef, XDM_NODE_KIND kind);
74
82 bool operator==(const XdmNode& other) const;
83
88 XdmNode(const XdmNode &other);
89
93 virtual ~XdmNode();
94
99 bool isAtomic();
100
105 XdmItem *getHead();
106
113 bool equals(XdmNode * other);
114
115
122 XDM_NODE_KIND getNodeKind();
123
130 const char *getNodeName();
131
138 const char *getLocalName();
139
145 XdmValue *getTypedValue();
146
151 int getLineNumber();
152
153
158 int getColumnNumber();
159
166 const char *getBaseUri();
167
178 const char *getStringValue(const char *encoding = nullptr);
179
180
207 const char *toString(const char *encoding = nullptr);
208
215 XdmNode *getParent();
216
226 const char *getAttributeValue(const char *name);
227
233 int getAttributeCount();
234
244 XdmNode **getAttributeNodes(bool cache = false);
245
259 XdmNode **axisNodes(EnumXdmAxis axis);
260
267 EnumXdmAxis convertEnumXdmAxis(int n) { return static_cast<EnumXdmAxis>(n); }
268
272 int axisNodeCount();
273
279
285 bool isNode() { return true; }
286
294 XdmNode **getChildren(bool cache = false);
295
305 XdmNode *getChild(int i, bool cache = false);
306
311 int getChildCount();
312
317 XDM_TYPE getType() { return XDM_NODE; }
318
319
323 void resetRelinquishedChildren();
324
328 void incrementRefCountForRelinquishedChildren();
329
334 bool hasRelinquishedChildren();
335
340 static void deleteChildrenArray(XdmNode **fetchedChildren) {
341 if (fetchedChildren != nullptr) {
342 delete[] fetchedChildren;
343 fetchedChildren = nullptr;
344 }
345 }
346
347
348private:
349 const char *baseURI;
350 const char *nodeName;
351 const char *localName;
352 XdmNode **children;
354 int childCount;
355 int axisCount;
356 XdmNode **attrValues;
358 int attrCount;
359 XDM_NODE_KIND nodeKind;
360};
361
362#endif
The class XdmItem represents an item in a sequence, as defined by the XDM data model.
Definition XdmItem.h:31
virtual const char * getStringValue(const char *encoding=nullptr)
Get the string value of the item.
Definition XdmItem.cpp:56
const char * toString(const char *encoding=nullptr)
Create a string representation of the item.
Definition XdmItem.cpp:71
virtual XdmItem * getHead()
Get the first item in the sequence consisting of just this item.
Definition XdmItem.cpp:41
virtual int64_t getUnderlyingValue()
Get the underlying Java XdmValue object - internal use only.
Definition XdmItem.cpp:52
virtual bool isAtomic()
Determine whether the item is an atomic value or some other type of item.
Definition XdmItem.cpp:31
This class represents a node in the XDM data model.
Definition XdmNode.h:57
XDM_TYPE getType()
Get the type of this XDM value.
Definition XdmNode.h:317
int64_t getUnderlyingValue()
Get the underlying Graalvm Java object for the XdmNode - internal use only.
Definition XdmNode.h:278
bool isNode()
Determine whether the item is a node or some other type of item.
Definition XdmNode.h:285
static void deleteChildrenArray(XdmNode **fetchedChildren)
Utility method required for the python and PHP extensions to delete a string created in the C++ code-...
Definition XdmNode.h:340
EnumXdmAxis convertEnumXdmAxis(int n)
Convert an int into the corresponding EnumXdmAxis Enum object.
Definition XdmNode.h:267
An XdmValue represents a value in the XDM data model.
Definition XdmValue.h:43