SaxonC  11.3
Saxon Processor library for C/C++, PHP and Python
Public Member Functions | List of all members
XdmNode Class Reference

#include <XdmNode.h>

Inheritance diagram for XdmNode:
XdmItem XdmValue

Public Member Functions

 XdmNode (jobject)
 XdmNode constructor created as a wrapper around an existing Saxon Java object. More...
 
 XdmNode (XdmNode *parent, jobject, XDM_NODE_KIND kind)
 XdmNode constructor created as a wrapper around an existing Saxon Java object. More...
 
virtual ~XdmNode ()
 Destructor. More...
 
virtual bool isAtomic ()
 Determine whether the item is an atomic value or some other type of item. More...
 
XdmItemgetHead ()
 Get the first item in the sequence. More...
 
XDM_NODE_KIND getNodeKind ()
 Get the kind of node. More...
 
const char * getNodeName ()
 Get the name of the node, as a string in the form of a EQName. More...
 
const char * getLocalName ()
 Get the local name of the node. More...
 
XdmValuegetTypedValue ()
 Get the typed value of this node, as defined in XDM. More...
 
const char * getBaseUri ()
 Get the base URI of this node. More...
 
const char * getStringValue ()
 Get the string value of the item. For a node, this gets the string value of the node. More...
 
const char * toString ()
 The toString() method returns a simple XML serialization of the node with defaulted serialization parameters. More...
 
XdmNodegetParent ()
 Get the parent of this node. More...
 
const char * getAttributeValue (const char *name)
 Get the string value of a named attribute (in no namespace) of this element. More...
 
int getAttributeCount ()
 Get the number of attribute node for this current node. More...
 
XdmNode ** getAttributeNodes (bool cache=false)
 Get array of attribute nodes of this element. More...
 
jobject getUnderlyingValue ()
 Get the underlying JNI Java object for the XdmNode. More...
 
bool isNode ()
 Determine whether the item is a node or some other type of item. More...
 
XdmNode ** getChildren (bool cache=false)
 Get all the child nodes from the current parent node. More...
 
XdmNodegetChild (int i, bool cache=false)
 Get the ith child nodes from the current parent node. More...
 
int getChildCount ()
 Get the count of child nodes from thie current node. More...
 
XDM_TYPE getType ()
 Get the type of the object. More...
 
- Public Member Functions inherited from XdmItem
 XdmItem ()
 XdmItem default constructor. More...
 
 XdmItem (jobject)
 XdmItem constructor created as a wrapper around an existing Saxon Java object. More...
 
 XdmItem (const XdmItem &item)
 Copy constructor. More...
 
virtual ~XdmItem ()
 Destructor. More...
 
virtual void incrementRefCount ()
 Increment reference count of this XdmItem - Memory management - Internal use only. More...
 
virtual void decrementRefCount ()
 Decrement reference count of this XdmItem - Memory management - Internal use only. More...
 
virtual bool isFunction ()
 
virtual bool isMap ()
 
virtual bool isArray ()
 
XdmItemitemAt (int n)
 
int size ()
 
- Public Member Functions inherited from XdmValue
 XdmValue ()
 A default Constructor. More...
 
 XdmValue (const XdmValue &other)
 A copy constructor. More...
 
XdmValueaddXdmValueWithType (const char *tStr, const char *val)
 Add an XdmItem to the sequence. More...
 
void addXdmItem (XdmItem *val)
 
void addUnderlyingValue (jobject val)
 
 XdmValue (jobject val, bool arrFlag)
 A Constructor for handling XdmArray - Internal user only. More...
 
 XdmValue (jobject val)
 A Constructor. More...
 
virtual ~XdmValue ()
 Destructor. More...
 
void releaseXdmValue ()
 Delete the XdmValue object and clean up all items in the sequence. Release the underlying JNI object.
 
int getRefCount ()
 Get the number of references on this XdmValue. More...
 

Additional Inherited Members

- Protected Member Functions inherited from XdmValue
void initialize ()
 initialize this XdmValue with default values
 
- Protected Attributes inherited from XdmItem
jobject value
 
std::string stringValue
 
- Protected Attributes inherited from XdmValue
char * valueType
 
std::vector< XdmItem * > values
 
int xdmSize
 
int refCount
 

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/2]

XdmNode::XdmNode ( jobject  obj)

XdmNode constructor created as a wrapper around an existing Saxon Java object.

XdmNode constructor created from a JNI Java object. This is for internal use only

Parameters
obj- The internal Java object for the XdmNode is wrapped here in the C++ XdmNode

◆ XdmNode() [2/2]

XdmNode::XdmNode ( XdmNode parent,
jobject  obj,
XDM_NODE_KIND  kind 
)

XdmNode constructor created as a wrapper around an existing Saxon Java object.

XdmNode constructor created from a JNI Java object. This is for internal use only

Parameters
parent- The parent XdmNode to this node object
obj- The internal Java object for the XdmNode is wrapped here in the C++ XdmNode
kind- The kind of node, for example XdmNodeKind::ELEMENT or XdmNodeKind::ATTRIBUTE

◆ ~XdmNode()

XdmNode::~XdmNode ( )
virtual

Destructor.

Destructor for XdmNode

Member Function Documentation

◆ getAttributeCount()

int XdmNode::getAttributeCount ( )

Get the number of attribute node for this current node.

Returns
returns the number of attributes on this node, other return zero if this node has no attributes or is not an element.

◆ getAttributeNodes()

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

Get array of attribute nodes of this element.

Parameters
cache- true to cache the attribute nodes for future use. User os responsible for memory management for the attribute nodes.
Returns
NULL if this node is not an element, or if this element has no attribute with the specified name. 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.

Parameters
namethe 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.

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 nodes from the current parent node.

Returns
a pointer to the ith child node

◆ getChildCount()

int XdmNode::getChildCount ( )

Get the count of child nodes from thie current node.

Returns
int for the count of child nodes

◆ getChildren()

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

Get all the child nodes from the current parent node.

Returns
pointer array of XdmNode objects

◆ getHead()

XdmItem * XdmNode::getHead ( )
virtual

Get the first item in the sequence.

Returns
XdmItem or nullptr if sequence is empty

Reimplemented from XdmItem.

◆ getLocalName()

const char * XdmNode::getLocalName ( )

Get the local name of the node.

Returns
the 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 node.

Returns
the kind of 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.

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 ( )
virtual

Get the string value of the item. For a node, this gets the string value of the node.

For an atomic value, it has the same effect as casting the value to a string. In all cases 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.

Returns
the result of converting the item to a string.
Remarks
the SaxonProcessor argument has been removed from release version 1.2.1

Reimplemented from XdmItem.

◆ getType()

XDM_TYPE XdmNode::getType ( )
inlinevirtual

Get the type of the object.

Returns
XDM_TYPE - Type of the XdmItem

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()

jobject XdmNode::getUnderlyingValue ( )
inlinevirtual

Get the underlying JNI Java object for the XdmNode.

Returns
jobject - The unwrapped JNI 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
true if the item is an atomic value, false if it is a node or a function (including maps and arrays)

Reimplemented from XdmItem.

◆ isNode()

bool XdmNode::isNode ( )
inlinevirtual

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

Returns
true if the item is a node, false if it is an atomic value or a function (including maps and arrays)

Reimplemented from XdmItem.

◆ toString()

const char * XdmNode::toString ( )
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.

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: