Project

Profile

Help

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

he / src / main / c / Saxon.C.API / XdmNode.h @ 339c45ee

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

    
40
        virtual bool isAtomic();
41

    
42

    
43
        XDM_NODE_KIND getNodeKind();
44

    
45
        /**
46
         * Get the name of the node, as a string in the form of a EQName
47
         *
48
         * @return the name of the node. In the case of unnamed nodes (for example, text and comment nodes)
49
         *         return nullptr.
50
         */
51
        const char * getNodeName();
52

    
53
        /**
54
         * Get the typed value of this node, as defined in XDM
55
         *
56
         * @return the typed value. If the typed value is a single atomic value, this will be returned
57
         * as an instance of {@link XdmAtomicValue}
58
         */
59
        XdmValue * getTypedValue();
60

    
61
        const char* getBaseUri();
62

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

    
77
        
78
        const char * toString();
79

    
80
        XdmNode* getParent();
81

    
82

    
83
        const char* getAttributeValue(const char *str);
84

    
85
        int getAttributeCount();
86

    
87
        XdmNode** getAttributeNodes();
88

    
89
        jobject getUnderlyingValue() {
90

    
91
                return XdmItem::getUnderlyingValue();
92

    
93
        }
94

    
95
    /**
96
     * Determine whether the item is a node or some other type of item
97
     *
98
     * @return true if the item is a node, false if it is an atomic value or a function (including maps and arrays)
99
     */
100
    bool isNode(){
101
        return true;
102
    }
103

    
104

    
105

    
106
        XdmNode** getChildren();
107

    
108
        int getChildCount();
109

    
110
        /**
111
   * Get the type of the object
112
   */
113
        XDM_TYPE getType() {
114
                return XDM_NODE;
115
        }
116

    
117
        // const char* getOuterXml();
118

    
119

    
120

    
121
private:
122
        const char * baseURI;
123
        const char * nodeName;
124
        XdmNode ** children; //caches child nodes when getChildren method is first called;
125
        int childCount;
126
        XdmNode * parent;
127
        XdmValue * typedValue;
128
        XdmNode ** attrValues;//caches attribute nodes when getAttributeNodes method is first called;
129
        int attrCount;
130
        XDM_NODE_KIND nodeKind;
131

    
132
};
133

    
134
#endif
(35-35/56)