SaxonC 12.7.0
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
XdmNode Class Reference

This class represents a node in the XDM data model. More...

#include <XdmNode.h>

Inheritance diagram for XdmNode:
XdmItem XdmValue

Public Member Functions

 XdmNode (int64_t objRef)
 XdmNode constructor to create an object which is a wrapper for a Java XdmNode object - internal use only.
 
 XdmNode (XdmNode *parent, int64_t objRef, XDM_NODE_KIND kind)
 XdmNode constructor to create an object which is a wrapper for a Java XdmNode object - internal use only.
 
bool operator== (const XdmNode &other) const
 XdmNode == operator.
 
 XdmNode (const XdmNode &other)
 XdmNode copy constructor.
 
virtual ~XdmNode ()
 Destructor method for XdmNode.
 
bool isAtomic ()
 Determine whether the item is an atomic value or some other type of item.
 
XdmItemgetHead ()
 Get the first item in the sequence consisting of just this item.
 
bool equals (XdmNode *other)
 The equals() relation between two XdmNode objects is true if they both represent the same node.
 
XDM_NODE_KIND getNodeKind ()
 Get the kind of the node.
 
const char * getNodeName ()
 Get the name of the node, as a string in the form of a EQName.
 
const char * getLocalName ()
 Get the local name of the node.
 
XdmValuegetTypedValue ()
 Get the typed value of this node, as defined in XDM.
 
int getLineNumber ()
 Get the line number of the node in a source document.
 
int getColumnNumber ()
 Get the column number of the node in a source document.
 
const char * getBaseUri ()
 Get the base URI of this node.
 
const char * getStringValue (const char *encoding=nullptr)
 Get the string value of the node.
 
const char * toString (const char *encoding=nullptr)
 The toString() method returns a simple XML serialization of the node with defaulted serialization parameters.
 
XdmNodegetParent ()
 Get the parent of this node.
 
const char * getAttributeValue (const char *name)
 Get the string value of a named attribute (in no namespace) of this element.
 
int getAttributeCount ()
 Get the number of attribute nodes for this node.
 
XdmNode ** getAttributeNodes (bool cache=false)
 Get the attribute nodes of this element as an array.
 
XdmNode ** axisNodes (EnumXdmAxis axis)
 Get the array of nodes reachable from this node via a given axis.
 
EnumXdmAxis convertEnumXdmAxis (int n)
 Convert an int into the corresponding EnumXdmAxis Enum object.
 
int axisNodeCount ()
 Get the number of nodes in the nodeAxis array, cached from the last call to axisNodes.
 
int64_t getUnderlyingValue ()
 Get the underlying Graalvm Java object for the XdmNode - internal use only.
 
bool isNode ()
 Determine whether the item is a node or some other type of item.
 
XdmNode ** getChildren (bool cache=false)
 Get all the child nodes of the current node.
 
XdmNodegetChild (int i, bool cache=false)
 Get the ith child node of the current node.
 
int getChildCount ()
 Get the number of child nodes of the current node.
 
XDM_TYPE getType ()
 Get the type of this XDM value.
 
void resetRelinquishedChildren ()
 Reset associated reference counts on XdmItems that have been relinquished - internal use only.
 
void incrementRefCountForRelinquishedChildren ()
 Increment the ref count for a relinquished child only once - internal use only.
 
bool hasRelinquishedChildren ()
 Check if child nodes have been relinquished - internal use only.
 
- Public Member Functions inherited from XdmItem
 XdmItem ()
 Default constructor.
 
 XdmItem (int64_t objRef)
 XdmItem constructor to create an object which is a wrapper for a Java XdmItem object - internal use only.
 
 XdmItem (const XdmItem &item)
 XdmItem copy constructor.
 
bool operator== (const XdmItem &other) const
 
virtual ~XdmItem ()
 Destructor method for XdmItem.
 
virtual void incrementRefCount ()
 Increment reference count of this XdmItem - internal use only.
 
virtual void decrementRefCount ()
 Decrement reference count of this XdmItem - internal use only.
 
virtual bool isFunction ()
 Determine whether the item is an XDM function or some other type of item.
 
virtual bool isMap ()
 Determine whether the item is an XDM map or some other type of item.
 
virtual bool isArray ()
 Determine whether the item is an XDM array or some other type of item.
 
XdmItemitemAt (int n)
 Get the n'th item in the sequence consisting of just this item, counting from zero.
 
int size ()
 Get the number of items in the sequence.
 
- Public Member Functions inherited from XdmValue
 XdmValue ()
 Default constructor.
 
 XdmValue (const XdmValue &other)
 XdmValue copy constructor.
 
void addXdmItem (XdmItem *val)
 Add an XdmItem to the sequence.
 
virtual bool operator== (const XdmValue &other) const
 
void addXdmItemFromUnderlyingValue (XdmItem *val)
 Add an XdmItem to the sequence, when the sequence was returned from SaxonC - internal use only.
 
void addUnderlyingValue (int64_t val)
 Add Java XdmValue object to the sequence.
 
 XdmValue (int64_t val, bool arrFlag)
 A Constructor for handling XdmArray - internal use only.
 
 XdmValue (int64_t val)
 XdmValue constructor to create an object which is a wrapper for a Java XdmValue object - internal use only.
 
virtual ~XdmValue ()
 Destructor method for XdmValue.
 
void releaseXdmValue ()
 Deprecated: this is deprecated and a no-op, the C++ destructor handles this case.
 
int getRefCount ()
 Get the number of references on this XdmValue - internal use only This method is used for internal memory management.
 
void resetRelinquishedItems ()
 Reset associated reference counts on XdmItems that have been relinquished - internal use only.
 
void incrementRefCountForRelinquishedValue (int i)
 Increment the ref count for a relinquished item only once - internal use only.
 

Static Public Member Functions

static void deleteChildrenArray (XdmNode **fetchedChildren)
 Utility method required for the python and PHP extensions to delete a string created in the C++ code-base - internal use only.
 

Additional Inherited Members

- Protected Member Functions inherited from XdmValue
void initialize ()
 Initialize this XdmValue with default values.
 
- Protected Attributes inherited from XdmItem
const char * stringValue
 
const char * itemToString
 
- Protected Attributes inherited from XdmValue
char * valueType
 
XdmItem ** values
 
char * relinquished_values
 
int values_cap
 
int xdmSize
 
int refCount
 
int64_t value
 

Detailed Description

This class represents a node in the XDM data model.

A Node is an XdmItem, and is therefore an XdmValue in its own right, and may also participate as one item within a sequence value.

The XdmNode interface exposes basic properties of the node, such as its name, its string value, and its typed value.

Note that node identity cannot be inferred from object identity. The same node may be represented by different XdmNode instances at different times, or even at the same time. The equals() method on this class can be used to test for node identity.

Constructor & Destructor Documentation

◆ XdmNode() [1/3]

XdmNode::XdmNode ( int64_t objRef)

XdmNode constructor to create an object which is a wrapper for a Java XdmNode object - internal use only.

Parameters
objRef- internal Java XdmNode object to be wrapped

◆ XdmNode() [2/3]

XdmNode::XdmNode ( XdmNode * parent,
int64_t objRef,
XDM_NODE_KIND kind )

XdmNode constructor to create an object which is a wrapper for a Java XdmNode object - internal use only.

Parameters
parent- the parent XdmNode to this node object
objRef- internal Java XdmNode object to be wrapped
kind- the kind of node, for example XdmNodeKind::ELEMENT or XdmNodeKind::ATTRIBUTE

◆ XdmNode() [3/3]

XdmNode::XdmNode ( const XdmNode & other)

XdmNode copy constructor.

Parameters
other- the node being copied

Member Function Documentation

◆ axisNodes()

XdmNode ** XdmNode::axisNodes ( EnumXdmAxis axis)

Get the array of nodes reachable from this node via a given axis.

The caller is responsible for deallocation of memory for the attribute nodes using delete.

Parameters
axis- identifies which axis is to be navigated. Axis options are as follows: ANCESTOR = 0, ANCESTOR_OR_SELF = 1, ATTRIBUTE = 2, CHILD = 3, DESCENDANT = 4, DESCENDANT_OR_SELF = 5, FOLLOWING = 6, FOLLOWING_SIBLING = 7, NAMESPACE = 8, PARENT = 9, PRECEDING = 10, PRECEDING_SIBLING = 11, SELF = 12
Returns
An array of nodes on the specified axis, starting from this node as the context node. The nodes are returned in axis order, that is, in document order for a forwards axis and in reverse document order for a reverse axis.

◆ convertEnumXdmAxis()

EnumXdmAxis XdmNode::convertEnumXdmAxis ( int n)
inline

Convert an int into the corresponding EnumXdmAxis Enum object.

Parameters
n- the integer value for the XDM axis
Returns
The corresponding EnumXdmAxis object

◆ deleteChildrenArray()

static void XdmNode::deleteChildrenArray ( XdmNode ** fetchedChildren)
inlinestatic

Utility method required for the python and PHP extensions to delete a string created in the C++ code-base - internal use only.

Parameters
fetchedChildren- the array of pointers to child nodes to be deleted

◆ equals()

bool XdmNode::equals ( XdmNode * other)

The equals() relation between two XdmNode objects is true if they both represent the same node.

That is, it corresponds to the "is" operator in XPath.

Parameters
other- the object to be compared
Returns
True if and only if the other object is an XdmNode instance representing the same node

◆ getAttributeCount()

int XdmNode::getAttributeCount ( )

Get the number of attribute nodes for this node.

Returns
The number of attributes on this node; returns zero if this node has no attributes or is not an element node.

◆ getAttributeNodes()

XdmNode ** XdmNode::getAttributeNodes ( bool cache = false)

Get the attribute nodes of this element as an array.

Parameters
cache- deprecated. The caller is responsible for deallocation of memory for the attribute nodes using delete.
Returns
NULL if this node is not an element node, or if this element has no attributes. Otherwise return the attribute nodes as a pointer array.

◆ getAttributeValue()

const char * XdmNode::getAttributeValue ( const char * name)

Get the string value of a named attribute (in no namespace) of this element.

The caller is responsible for deallocation of memory for the attribute nodes using operator delete.

Parameters
name- the name of the required attribute, interpreted as a no-namespace name
Returns
NULL if this node is not an element, or if this element has no attribute with the specified name. Otherwise return the string value of the selected attribute node.

◆ getBaseUri()

const char * XdmNode::getBaseUri ( )

Get the base URI of this node.

Memory deallocation is handled internally.

Returns
The base URI, as defined in the XDM model. The value may be null if no base URI is known for the node, for example if the tree was built from a StreamSource with no associated URI, or if the node has no parent.

◆ getChild()

XdmNode * XdmNode::getChild ( int i,
bool cache = false )

Get the ith child node of the current node.

The caller is responsible for deallocation of memory using delete.

Parameters
i- the index of the required child node
cache- deprecated and will be removed in a later version. Caching is no longer used, the value of cache is ignored.
Returns
Pointer to the ith child node

◆ getChildCount()

int XdmNode::getChildCount ( )

Get the number of child nodes of the current node.

Returns
The number of child nodes as an int

◆ getChildren()

XdmNode ** XdmNode::getChildren ( bool cache = false)

Get all the child nodes of the current node.

The caller is responsible for deallocation of memory using delete.

Parameters
cache- deprecated and will be removed in a later version. Caching is no longer used, the value of cache is ignored.
Returns
Pointer array of XdmNode objects representing the child nodes

◆ getColumnNumber()

int XdmNode::getColumnNumber ( )

Get the column number of the node in a source document.

Returns
The column number of the node, or -1 if not available.

◆ getHead()

XdmItem * XdmNode::getHead ( )
virtual

Get the first item in the sequence consisting of just this item.

Returns
This XdmNode

Reimplemented from XdmItem.

◆ getLineNumber()

int XdmNode::getLineNumber ( )

Get the line number of the node in a source document.

Returns
The line number of the node, or -1 if not available.

◆ getLocalName()

const char * XdmNode::getLocalName ( )

Get the local name of the node.

Memory deallocation is handled internally.

Returns
The local name of the node. In the case of unnamed nodes (for example, text and comment nodes) return nullptr.

◆ getNodeKind()

XDM_NODE_KIND XdmNode::getNodeKind ( )

Get the kind of the node.

Returns
The kind of the node, for example XdmNodeKind::ELEMENT or XdmNodeKind::ATTRIBUTE

◆ getNodeName()

const char * XdmNode::getNodeName ( )

Get the name of the node, as a string in the form of a EQName.

Memory deallocation is handled internally.

Returns
The name of the node. In the case of unnamed nodes (for example, text and comment nodes) return NULL.

◆ getParent()

XdmNode * XdmNode::getParent ( )

Get the parent of this node.

Returns
The parent of this node (a document or element node), or NULL if this node has no parent.

◆ getStringValue()

const char * XdmNode::getStringValue ( const char * encoding = nullptr)
virtual

Get the string value of the node.

The result is the same as applying the XPath string() function.

For atomic values, the result is the same as the result of calling toString. This is not the case for nodes, where toString returns an XML serialization of the node.

The caller is responsible for memory deallocation using operator delete.

Parameters
encoding- the encoding of the string returned. If NULL or omitted defaults to the JVM encoding, which in most cases is UTF-8.
Returns
The string value of the node.

Reimplemented from XdmItem.

◆ getType()

XDM_TYPE XdmNode::getType ( )
inlinevirtual

Get the type of this XDM value.

Returns
The type of the XdmValue as an XDM_TYPE

Reimplemented from XdmItem.

◆ getTypedValue()

XdmValue * XdmNode::getTypedValue ( )

Get the typed value of this node, as defined in XDM.

Returns
The typed value. If the typed value is a single atomic value, this will be returned as an instance of XdmAtomicValue

◆ getUnderlyingValue()

int64_t XdmNode::getUnderlyingValue ( )
inlinevirtual

Get the underlying Graalvm Java object for the XdmNode - internal use only.

Returns
The unwrapped Graalvm object for the XdmNode

Reimplemented from XdmItem.

◆ isAtomic()

bool XdmNode::isAtomic ( )
virtual

Determine whether the item is an atomic value or some other type of item.

Returns
False

Reimplemented from XdmItem.

◆ isNode()

bool XdmNode::isNode ( )
inlinevirtual

Determine whether the item is a node or some other type of item.

Returns
True

Reimplemented from XdmItem.

◆ operator==()

bool XdmNode::operator== ( const XdmNode & other) const

XdmNode == operator.

Corresponds to the equals() relation - which is true between two XdmNode objects if they both represent the same node. That is, it corresponds to the "is" operator in XPath.

Parameters
other- the object to be compared
Returns
True if and only if the other object is an XdmNode instance representing the same node

◆ toString()

const char * XdmNode::toString ( const char * encoding = nullptr)
virtual

The toString() method returns a simple XML serialization of the node with defaulted serialization parameters.

In the case of an element node, the result will be a well-formed XML document serialized as defined in the W3C XSLT/XQuery serialization specification, using options method="xml", indent="yes", omit-xml-declaration="yes".

In the case of a document node, the result will be a well-formed XML document provided that the document node contains exactly one element child, and no text node children. In other cases it will be a well-formed external general parsed entity.

In the case of an attribute node, the output is a string in the form name="value". The name will use the original namespace prefix.

In the case of a namespace node, the output is a string in the form of a namespace declaration, that is xmlns="uri" or xmlns:pre="uri".

Other nodes, such as text nodes, comments, and processing instructions, are represented as they would appear in lexical XML. Note: this means that in the case of text nodes, special characters such as & and < are output in escaped form. To get the unescaped string value of a text node, use getStringValue() instead.

The caller is responsible for memory deallocation using operator delete.

Parameters
encoding- the encoding of the string returned. If NULL or omitted defaults to the JVM encoding, which in most cases is UTF-8.
Returns
A simple XML serialization of the node. Under error conditions the method may return an error message which will always begin with the label "Error: ".

Reimplemented from XdmItem.


The documentation for this class was generated from the following files: