Project

Profile

Help

How to connect?
Download (3.58 KB) Statistics
| Branch: | Revision:

he / src / main / c / Saxon.C.API / XdmNode.h @ 85a9912e

1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright (c) 2021 Saxonica Limited.
3
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
// This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7

    
8
#ifndef SAXON_XDMNODE_h
9
#define SAXON_XDMNODE_h
10

    
11
#include "XdmItem.h"
12
#include <string.h>
13

    
14
typedef enum eXdmNodeKind { DOCUMENT = 9, ELEMENT = 1, ATTRIBUTE = 2, TEXT = 3, COMMENT = 8, PROCESSING_INSTRUCTION = 7, NAMESPACE = 13, UNKNOWN = 0 } XDM_NODE_KIND;
15

    
16

    
17

    
18
class XdmValue;
19

    
20
class XdmNode : public XdmItem
21
{
22

    
23
public:
24

    
25

    
26
        /* XdmNode(const XdmValue& valuei){
27
         //value = (sxnc_value *)malloc(sizeof(sxnc_value));
28
                 value = valuei.values[0]->getUnderlyingCValue();
29
         xdmSize =1;
30
         refCount = 1;
31
         nodeKind = UNKNOWN;
32
         }*/
33

    
34
        XdmNode(jobject);
35

    
36
        XdmNode(XdmNode *parent, jobject, XDM_NODE_KIND);
37

    
38
        virtual ~XdmNode() {
39
                if (getRefCount() <1){
40
                    delete baseURI;
41
                        delete nodeName;
42
                }
43

    
44
                //There might be potential issues with children and attribute node not being deleted when the parent node has been deleted
45
        }
46

    
47
        virtual bool isAtomic();
48

    
49

    
50
        XDM_NODE_KIND getNodeKind();
51

    
52
        /**
53
         * Get the name of the node, as a string in the form of a EQName
54
         *
55
         * @return the name of the node. In the case of unnamed nodes (for example, text and comment nodes)
56
         *         return nullptr.
57
         */
58
        const char * getNodeName();
59

    
60
        /**
61
         * Get the typed value of this node, as defined in XDM
62
         *
63
         * @return the typed value. If the typed value is a single atomic value, this will be returned
64
         * as an instance of {@link XdmAtomicValue}
65
         */
66
        XdmValue * getTypedValue();
67

    
68
        const char* getBaseUri();
69

    
70
        /**
71
         * Get the string value of the item. For a node, this gets the string value
72
         * of the node. For an atomic value, it has the same effect as casting the value
73
         * to a string. In all cases the result is the same as applying the XPath string()
74
         * function.
75
         * <p>For atomic values, the result is the same as the result of calling
76
         * <code>toString</code>. This is not the case for nodes, where <code>toString</code>
77
         * returns an XML serialization of the node.</p>
78
         *
79
         * @return the result of converting the item to a string.
80
         * @deprecated the SaxonProcessor argument. It has been removed from release version 1.2.1
81
         */
82
        const char * getStringValue();
83

    
84
        
85
        const char * toString();
86

    
87
        XdmNode* getParent();
88

    
89

    
90
        const char* getAttributeValue(const char *str);
91

    
92
        int getAttributeCount();
93

    
94
        XdmNode** getAttributeNodes();
95

    
96
        jobject getUnderlyingValue() {
97

    
98
                return XdmItem::getUnderlyingValue();
99

    
100
        }
101

    
102
    /**
103
     * Determine whether the item is a node or some other type of item
104
     *
105
     * @return true if the item is a node, false if it is an atomic value or a function (including maps and arrays)
106
     */
107
    bool isNode(){
108
        return true;
109
    }
110

    
111

    
112

    
113
        XdmNode** getChildren();
114

    
115
        int getChildCount();
116

    
117
        /**
118
   * Get the type of the object
119
   */
120
        XDM_TYPE getType() {
121
                return XDM_NODE;
122
        }
123

    
124
        // const char* getOuterXml();
125

    
126

    
127

    
128
private:
129
        const char * baseURI;
130
        const char * nodeName;
131
        XdmNode ** children; //caches child nodes when getChildren method is first called;
132
        int childCount;
133
        XdmNode * parent;
134
        XdmValue * typedValue;
135
        XdmNode ** attrValues;//caches attribute nodes when getAttributeNodes method is first called;
136
        int attrCount;
137
        XDM_NODE_KIND nodeKind;
138

    
139
};
140

    
141
#endif
(34-34/55)