Project

Profile

Help

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

he / latest10 / hec / Saxon.C.API / XdmNode.h @ 6304fb8b

1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright (c) 2015 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
//#include "XdmValue.h"
14

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

    
17

    
18

    
19
class XdmValue;
20

    
21
class XdmNode : public XdmItem
22
{
23

    
24
public:
25

    
26

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

    
35
        XdmNode(jobject);
36

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

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

    
45
                //There might be potential issues with children and attribute node not being deleted when the parent node has been deleted
46
                //we need to track this kind of problem.
47
        }
48

    
49
        virtual bool isAtomic();
50

    
51

    
52
        XDM_NODE_KIND getNodeKind();
53

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

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

    
70
        const char* getBaseUri();
71

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

    
86
        
87
        const char * toString();
88

    
89
        XdmNode* getParent();
90

    
91

    
92
        const char* getAttributeValue(const char *str);
93

    
94
        int getAttributeCount();
95

    
96
        XdmNode** getAttributeNodes();
97

    
98
        jobject getUnderlyingValue() {
99

    
100
                return XdmItem::getUnderlyingValue();
101

    
102
        }
103

    
104

    
105
        XdmNode** getChildren();
106

    
107
        int getChildCount();
108

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

    
116
        // const char* getOuterXml();
117

    
118

    
119

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

    
131
};
132

    
133
#endif
(28-28/49)