PyXdmNode¶
- class PyXdmNode¶
Bases:
PyXdmItemThis class represents a node in the XDM data model. A PyXdmNode is a PyXdmItem, and is therefore a PyXdmValue in its own right, and may also participate as one item within a sequence value. The PyXdmNode interface exposes basic properties of the node, such as its name, its string value, and its typed value.
Creates a new instance, keeping a reference to its PySaxonProcessor :param processor:
- __getitem__(self, index)¶
Implement the built-in subscript operator (i.e. square brackets []) to return the ith child node of the current node
- Returns:
The child node at the specified index. If the child node at the index does not exist returns None.
- Return type:
- __len__(self)¶
Implement the built-in function len() to return the count of child nodes from this current node.
- Returns:
The count of child nodes
- Return type:
- classmethod __new__(*args, **kwargs)¶
- __pyx_vtable__ = <capsule object NULL>¶
- __reduce__()¶
Helper for pickle.
- __repr__()¶
___repr__(self)
- __setstate__()¶
- __str__(self)¶
The string value of the node as returned by the toString method :returns: String value of this node :rtype: str
- attribute_count¶
Get the number of attribute nodes on this node. If the node is not an element node then returns 0. :returns: The number of attribute nodes :rtype: int
- attributes¶
attribute_nodes(self) Get the attribute nodes of this node as a list of PyXdmNode objects :returns: List of PyXdmNode objects :rtype: list[PyXdmNode]
- axis_nodes(self, int axis)¶
Get the array of nodes reachable from this node via a given axis. Deprecated the argument type for axis will change from Saxon 13 to use the XdmNodeKind enum type 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 :param axis: Identifies which axis is to be navigated. :type axis: int
- base_uri¶
Base URI property. Get the Base URI for the node, that is, the URI used for resolving a relative URI contained in the node. This will be the same as the System ID unless xml:base has been used. Where the node does not have a base URI of its own, the base URI of its parent node is returned. :returns:
- String value of the base uri for this node. This may be NULL if the base URI is unknown,
including the case where the node has no parent.
- Return type:
- children¶
Get the children of this node as a list of PyXdmNode objects :returns: List of PyXdmNode objects :rtype: list[PyXdmNode]
- column_number¶
Get the column number of the node in a source document. :returns: The column number of the node, or -1 if not available. :rtype: int
- equals(self, 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. :param other: The object to be compared :type other: PyXdmNode
- Returns:
true if and only if the other object is an XdmNode instance representing the same node
- Return type:
- get_attribute_value(self, name, encoding=None)¶
Get the value of a named attribute :param name: the EQName of the required attribute :type name: str :param encoding: The encoding of the name argument. Argument can be omitted or None.
If not specified then the platform default encoding is used.
- get_parent(self)¶
Get the current node’s parent. If it does not exist return None. :returns: The parent node as a PyXdmNode object, or otherwise None :rtype: PyXdmNode
- get_string_value(self, encoding=None)¶
Property to get the string value of the node as defined in the XPath data model :param encoding: The encoding of the string. If not specified then the platform default encoding is used. :type encoding: str
- Returns:
The string value of this node
- Return type:
- head¶
Property to get the first item in the sequence represented by this PyXdmNode. Since a PyXdmItem is a sequence of length one, this returns the PyXdmNode itself. :returns: The PyXdmNode or None if the sequence is empty :rtype: PyXdmNode
- line_number¶
Get the line number of the node in a source document. :returns: The line number of the node, or -1 if not available. :rtype: int
- local_name¶
Get the local name of the node, as a string :returns: the local name of the node. In the case of unnamed nodes (e.g. text and comment nodes) returns None :rtype: str
- name¶
Get the name of the node, as a string in the form of an EQName :returns: the name of the node. In the case of unnamed nodes (e.g. text and comment nodes) returns None :rtype: str
- node_kind¶
Node kind property. There are seven kinds of node: documents=9, elements = 1, attributes =2, text=3, comments = 8, processing-instructions = 7, and namespaces=13. :returns: an integer identifying the kind of node. These integer values are the same as those used in the DOM :rtype: int
- node_kind_str¶
‘document’, ‘element’, ‘attribute’, ‘text’, ‘comment’, ‘processing-instruction’, ‘namespace’, ‘unknown’. :returns: a string identifying the kind of node. :rtype: str
- Type:
Node kind property string. Returns one of the following
- string_value¶
Property to get the string value of the node as defined in the XPath data model :returns: The string value of this node :rtype: str
- to_string(self, encoding=None)¶
The string value of the node as returned by the toString method :param encoding: The encoding of the string. If not specified then the platform default encoding is used. :type encoding: str
- Returns:
String value of this node
- Return type:
- typed_value¶
Get the typed value of this node, as defined in the XPath data model :returns: the typed value. If the typed value is a single atomic value, this will be returned
as an instance of PyXdmAtomicValue
- Return type: