PyXdmMap¶
- class PyXdmMap¶
Bases:
PyXdmFunctionItemThe class PyXdmMap represents a map item in the XDM data model. A map is a list of zero or more entries, each of which is a pair comprising a key (which is an atomic value) and a value (which is an arbitrary value). The map itself is an XDM item. A PyXdmMap is immutable.
Creates a new instance, keeping a reference to its PySaxonProcessor :param processor:
- __iter__(self)¶
Returns the Iterator object of PyXdmMap
- classmethod __new__(*args, **kwargs)¶
- __pyx_vtable__ = <capsule object NULL>¶
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setstate__()¶
- __str__()¶
Return str(self).
- contains_key(self, PyXdmAtomicValue key)¶
Returns true if this map contains a mapping for the specified key. :param key: key whose presence in this map is to be tested :type key: PyXdmAtomicValue
- Returns:
true if this map contains a mapping for the specified key
- Return type:
- get(self, key, encoding=None)¶
Returns the value to which the specified key is mapped, or NULL if this map contains no mapping for the key. All keys in the PyXdmMap are of type PyXdmAtomicValue, but for convenience, this method also accepts keys of primitive type (str, int and float), which will be converted to PyXdmAtomicValue internally. :param key: the key whose associated value is to be returned. The key supports the following types:
PyXdmAtomicValue, str, int and float
- Parameters:
encoding (str) – The encoding of the key, if supplied as a string. If not specified then the platform default encoding is used.
- Returns:
the value to which the specified key is mapped, or NULL if this map contains no mapping for the key
- Return type:
- isEmpty¶
Returns true if this map contains no key-value mappings. :returns: true if this map contains no key-value mappings :rtype: bool
- keys(self)¶
Get the keys in the PyXdmMap :returns: List of PyXdmAtomicValue objects :rtype: list[PyXdmAtomicValue]
- map_size¶
Get the number of entries in the map :returns: the number of entries in the map. (Note that the size() method returns 1 (one), because an XDM
map is an item.)
- Return type:
- put(self, PyXdmAtomicValue key, PyXdmValue value)¶
Create a new map containing an additional (key, value) pair. If there is an existing entry with the same key, it is replaced. :param key: The key for the new map entry :type key: PyXdmAtomicValue :param value: The value for the new map entry :type value: PyXdmValue
- Returns:
a new map containing the new entry. The original map is unchanged.
- Return type:
- remove(self, PyXdmAtomicValue key)¶
Create a new map in which the entry for a given key has been removed. :param key: The key to be removed given as an PyXdmAtomicValue :type key: PyXdmAtomicValue
- Returns:
a map without the specified entry. The original map is unchanged.
- Return type:
- string_value¶
Property to get the string value of the PyXdmMap :returns: String value of the map item :rtype: str
- values(self)¶
Get the values found in this map, that is, the value parts of the key-value pairs. :returns: List of the values found in this map. :rtype: list