libSBML Python API
5.18.0
|
This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.
This class serves to organize functionality for tracking XML namespaces in a document or data stream. The namespace declarations are stored as a list of pairs of XML namespace URIs and prefix strings. These correspond to the parts of a namespace declaration on an XML element. For example, in the following XML fragment,
<annotation> <mysim:nodecolors xmlns:mysim='urn:lsid:mysim.org' mysim:bgcolor='green' mysim:fgcolor='white'/> </annotation>
there is one namespace declaration. Its URI is urn:lsid:mysim.org
and its prefix is mysim
. This pair could be stored as one item in an XMLNamespaces list.
XMLNamespaces provides various methods for manipulating the list of prefix-URI pairs. Individual namespaces stored in a given XMLNamespace object instance can be retrieved based on their index using XMLNamespaces.getPrefix(), or by their characteristics such as their URI or position in the list.
Public Member Functions | |
def | __init__ (self, args) |
This method has multiple variants; they differ in the arguments they accept. More... | |
def | add (self, args) |
Appends an XML namespace prefix and URI pair to this list of namespace declarations. More... | |
def | clear (self) |
Clears (deletes) all XML namespace declarations in this XMLNamespaces object. More... | |
def | clone (self) |
Creates and returns a deep copy of this XMLNamespaces object. More... | |
def | containsUri (self, uri) |
Tests whether the given uri is contained in this set of namespaces. More... | |
def | getIndex (self, uri) |
Look up the index of an XML namespace declaration by URI. More... | |
def | getIndexByPrefix (self, prefix) |
Look up the index of an XML namespace declaration by prefix . More... | |
def | getLength (self) |
Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces instance. More... | |
def | getNumNamespaces (self) |
Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces instance. More... | |
def | getPrefix (self, args) |
This method has multiple variants; they differ in the arguments they accept. More... | |
def | getURI (self, args) |
This method has multiple variants; they differ in the arguments they accept. More... | |
def | hasNS (self, uri, prefix) |
Predicate returning True or False depending on whether an XML Namespace with the given URI and prefix pair is contained in this XMLNamespaces list. More... | |
def | hasPrefix (self, prefix) |
Predicate returning True or False depending on whether an XML Namespace with the given prefix is contained in this XMLNamespaces list. More... | |
def | hasURI (self, uri) |
Predicate returning True or False depending on whether an XML Namespace with the given URI is contained in this XMLNamespaces list. More... | |
def | isEmpty (self) |
Predicate returning True or False depending on whether this XMLNamespaces list is empty. More... | |
def | remove (self, args) |
This method has multiple variants; they differ in the arguments they accept. More... | |
def libsbml.XMLNamespaces.__init__ | ( | self, | |
args | |||
) |
This method has multiple variants; they differ in the arguments they accept.
__init__() XMLNamespaces __init__(XMLNamespaces orig) XMLNamespaces
Each variant is described separately below.
XMLNamespaces()
Creates a new empty list of XML namespace declarations.
XMLNamespaces(XMLNamespaces orig)
Copy constructor; creates a copy of this XMLNamespaces list.
orig | the XMLNamespaces object to copy. |
def libsbml.XMLNamespaces.add | ( | self, | |
args | |||
) |
Appends an XML namespace prefix and URI pair to this list of namespace declarations.
add(string uri, string prefix) int add(string uri) int
An XMLNamespaces object stores a list of pairs of namespaces and their prefixes. If there is an XML namespace with the given uri
prefix in this list, then its corresponding URI will be overwritten by the new uri
unless the uri represents the core sbml namespace. Calling programs could use one of the other XMLNamespaces methods, such as XMLNamespaces.hasPrefix() and XMLNamespaces.hasURI() to inquire whether a given prefix and/or URI is already present in this XMLNamespaces object. If the uri
represents the sbml namespaces then it will not be overwritten, as this has potentially serious consequences. If it is necessary to replace the sbml namespace the namespace should be removed prior to adding the new namespace.
uri | a string, the uri for the namespace. |
prefix | a string, the prefix for the namespace. |
parameter
= value
. This is not to be intepreted as a Python keyword argument; the use of a parameter name followed by an equals sign followed by a value is only meant to indicate a default value if the argument is not provided at all. It is not a keyword in the Python sense. def libsbml.XMLNamespaces.clear | ( | self | ) |
Clears (deletes) all XML namespace declarations in this XMLNamespaces object.
clear() int
def libsbml.XMLNamespaces.clone | ( | self | ) |
Creates and returns a deep copy of this XMLNamespaces object.
clone() XMLNamespaces
def libsbml.XMLNamespaces.containsUri | ( | self, | |
uri | |||
) |
Tests whether the given uri is contained in this set of namespaces.
containsUri(string uri) bool
def libsbml.XMLNamespaces.getIndex | ( | self, | |
uri | |||
) |
Look up the index of an XML namespace declaration by URI.
getIndex(string uri) int
An XMLNamespaces object stores a list of pairs of namespaces and their prefixes. If this XMLNamespaces object contains a pair with the given URI uri
, this method returns its index in the list.
uri | a string, the URI of the sought-after namespace. |
-1
if not present. def libsbml.XMLNamespaces.getIndexByPrefix | ( | self, | |
prefix | |||
) |
Look up the index of an XML namespace declaration by prefix
.
getIndexByPrefix(string prefix) int
An XMLNamespaces object stores a list of pairs of namespaces and their prefixes. If this XMLNamespaces object contains a pair with the given prefix prefix
, this method returns its index in the list.
prefix | a string, the prefix string of the sought-after namespace. |
-1
if not present. def libsbml.XMLNamespaces.getLength | ( | self | ) |
Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces instance.
getLength() int
def libsbml.XMLNamespaces.getNumNamespaces | ( | self | ) |
Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces instance.
getNumNamespaces() int
This function is an alias for getLength introduced for consistency with other XML classes.
def libsbml.XMLNamespaces.getPrefix | ( | self, | |
args | |||
) |
This method has multiple variants; they differ in the arguments they accept.
getPrefix(int index) string getPrefix(string uri) string
Each variant is described separately below.
getPrefix(int index)
Look up the prefix of an XML namespace declaration by its position.
An XMLNamespaces object stores a list of pairs of namespaces and their prefixes. This method returns the prefix of the n
th element in that list (if it exists). Callers should use XMLAttributes.getLength() first to find out how many namespaces are stored in the list.
index | an integer, position of the sought-after prefix. |
index
is out of range.getPrefix(string uri)
Look up the prefix of an XML namespace declaration by its URI.
An XMLNamespaces object stores a list of pairs of namespaces and their prefixes. This method returns the prefix for a pair that has the given uri
.
uri | a string, the URI of the prefix being sought. |
uri
exists in this XMLNamespaces object. def libsbml.XMLNamespaces.getURI | ( | self, | |
args | |||
) |
This method has multiple variants; they differ in the arguments they accept.
getURI(int index) string getURI(string prefix) string getURI() string
Each variant is described separately below.
getURI(string prefix = '')
Look up the URI of an XML namespace declaration by its prefix.
An XMLNamespaces object stores a list of pairs of namespaces and their prefixes. This method returns the namespace URI for a pair that has the given prefix
.
prefix | a string, the prefix of the required URI. |
prefix
, or an empty string if no such prefix-and-URI pair exists in this XMLNamespaces object.parameter
= value
. This is not to be intepreted as a Python keyword argument; the use of a parameter name followed by an equals sign followed by a value is only meant to indicate a default value if the argument is not provided at all. It is not a keyword in the Python sense.getURI(int index)
Look up the URI of an XML namespace declaration by its position.
An XMLNamespaces object stores a list of pairs of namespaces and their prefixes. This method returns the URI of the n
th element in that list (if it exists). Callers should use XMLAttributes.getLength() first to find out how many namespaces are stored in the list.
index | an integer, position of the required URI. |
index
is out of range.def libsbml.XMLNamespaces.hasNS | ( | self, | |
uri, | |||
prefix | |||
) |
Predicate returning True
or False
depending on whether an XML Namespace with the given URI and prefix pair is contained in this XMLNamespaces list.
hasNS(string uri, string prefix) bool
uri | a string, the URI for the namespace. |
prefix | a string, the prefix for the namespace. |
True
if an XML Namespace with the given uri/prefix pair is contained in this XMLNamespaces list, False
otherwise. def libsbml.XMLNamespaces.hasPrefix | ( | self, | |
prefix | |||
) |
Predicate returning True
or False
depending on whether an XML Namespace with the given prefix is contained in this XMLNamespaces list.
hasPrefix(string prefix) bool
prefix | a string, the prefix for the namespace. |
True
if an XML Namespace with the given URI is contained in this XMLNamespaces list, False
otherwise. def libsbml.XMLNamespaces.hasURI | ( | self, | |
uri | |||
) |
Predicate returning True
or False
depending on whether an XML Namespace with the given URI is contained in this XMLNamespaces list.
hasURI(string uri) bool
uri | a string, the uri for the namespace. |
True
if an XML Namespace with the given URI is contained in this XMLNamespaces list, False
otherwise. def libsbml.XMLNamespaces.isEmpty | ( | self | ) |
Predicate returning True
or False
depending on whether this XMLNamespaces list is empty.
isEmpty() bool
True
if this XMLNamespaces list is empty, False
otherwise. def libsbml.XMLNamespaces.remove | ( | self, | |
args | |||
) |
This method has multiple variants; they differ in the arguments they accept.
remove(int index) int remove(string prefix) int
Each variant is described separately below.
remove(int index)
Removes an XML Namespace stored in the given position of this list.
index | an integer, position of the namespace to remove. |
remove(string prefix)
Removes an XML Namespace with the given prefix.
prefix | a string, prefix of the required namespace. |