libSBML C 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_t list.
XMLNamespaces_t 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_t::getPrefix(int index), or by their characteristics such as their URI or position in the list.
Public Member Functions | |
LIBLAX_EXTERN int | XMLNamespaces_add (XMLNamespaces_t *ns, const char *uri, const char *prefix) |
Appends an XML namespace prefix/URI pair to this XMLNamespaces_t structure. More... | |
LIBLAX_EXTERN int | XMLNamespaces_clear (XMLNamespaces_t *ns) |
Clears this XMLNamespaces_t structure. More... | |
LIBLAX_EXTERN XMLNamespaces_t * | XMLNamespaces_clone (const XMLNamespaces_t *ns) |
Creates a deep copy of the given XMLNamespaces_t structure. More... | |
LIBLAX_EXTERN XMLNamespaces_t * | XMLNamespaces_create (void) |
Creates a new empty XMLNamespaces_t structure. More... | |
LIBLAX_EXTERN void | XMLNamespaces_free (XMLNamespaces_t *ns) |
Frees the given XMLNamespaces_t structure. More... | |
LIBLAX_EXTERN int | XMLNamespaces_getIndex (const XMLNamespaces_t *ns, const char *uri) |
Lookup the index of an XML namespace declaration by URI. More... | |
LIBLAX_EXTERN int | XMLNamespaces_getIndexByPrefix (const XMLNamespaces_t *ns, const char *prefix) |
Look up the index of an XML namespace declaration by prefix . More... | |
LIBLAX_EXTERN int | XMLNamespaces_getLength (const XMLNamespaces_t *ns) |
Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces_t instance. More... | |
LIBLAX_EXTERN int | XMLNamespaces_getNumNamespaces (const XMLNamespaces_t *ns) |
Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces_t instance. More... | |
LIBLAX_EXTERN char * | XMLNamespaces_getPrefix (const XMLNamespaces_t *ns, int index) |
Look up the prefix of an XML namespace declaration by its position. More... | |
LIBLAX_EXTERN char * | XMLNamespaces_getPrefixByURI (const XMLNamespaces_t *ns, const char *uri) |
Look up the prefix of an XML namespace declaration by its URI. More... | |
LIBLAX_EXTERN char * | XMLNamespaces_getURI (const XMLNamespaces_t *ns, int index) |
Look up the URI of an XML namespace declaration by its position. More... | |
LIBLAX_EXTERN char * | XMLNamespaces_getURIByPrefix (const XMLNamespaces_t *ns, const char *prefix) |
Look up the URI of an XML namespace declaration by its prefix. More... | |
LIBLAX_EXTERN int | XMLNamespaces_hasNS (const XMLNamespaces_t *ns, const char *uri, const char *prefix) |
Predicate returning 1 (true) or 0 (false) depending on whether an XML Namespace with the given URI is contained in this XMLNamespaces_t list. More... | |
LIBLAX_EXTERN int | XMLNamespaces_hasPrefix (const XMLNamespaces_t *ns, const char *prefix) |
Predicate returning 1 (true) or 0 (false) depending on whether an XML Namespace the given prefix is contained in this XMLNamespaces_t list. More... | |
LIBLAX_EXTERN int | XMLNamespaces_hasURI (const XMLNamespaces_t *ns, const char *uri) |
Predicate returning 1 (true) or 0 (false) depending on whether an XML Namespace with the given URI is contained in this XMLNamespaces_t list. More... | |
LIBLAX_EXTERN int | XMLNamespaces_isEmpty (const XMLNamespaces_t *ns) |
Predicate returning 1 (true) or 0 (false) depending on whether this XMLNamespaces_t list is empty. More... | |
LIBLAX_EXTERN int | XMLNamespaces_remove (XMLNamespaces_t *ns, int index) |
Removes an XML Namespace stored in the given position of this list. More... | |
LIBLAX_EXTERN int | XMLNamespaces_removeByPrefix (XMLNamespaces_t *ns, const char *prefix) |
Removes an XML Namespace with the given prefix . More... | |
LIBLAX_EXTERN int XMLNamespaces_add | ( | XMLNamespaces_t * | ns, |
const char * | uri, | ||
const char * | prefix | ||
) |
Appends an XML namespace prefix/URI pair to this XMLNamespaces_t structure.
ns | the XMLNamespaces_t structure. |
uri | a string, the uri for the namespace. |
prefix | a string, the prefix for the namespace. |
LIBLAX_EXTERN int XMLNamespaces_clear | ( | XMLNamespaces_t * | ns | ) |
Clears this XMLNamespaces_t structure.
ns | XMLNamespaces_t structure. |
LIBLAX_EXTERN XMLNamespaces_t * XMLNamespaces_clone | ( | const XMLNamespaces_t * | ns | ) |
Creates a deep copy of the given XMLNamespaces_t structure.
ns | the XMLNamespaces_t structure to be copied. |
LIBLAX_EXTERN XMLNamespaces_t * XMLNamespaces_create | ( | void | ) |
Creates a new empty XMLNamespaces_t structure.
LIBLAX_EXTERN void XMLNamespaces_free | ( | XMLNamespaces_t * | ns | ) |
Frees the given XMLNamespaces_t structure.
ns | XMLNamespaces_t structure to be freed. |
LIBLAX_EXTERN int XMLNamespaces_getIndex | ( | const XMLNamespaces_t * | ns, |
const char * | uri | ||
) |
Lookup the index of an XML namespace declaration by URI.
ns | the XMLNamespaces_t structure. |
uri | a string, uri of the required namespace. |
-1
if not present. LIBLAX_EXTERN int XMLNamespaces_getIndexByPrefix | ( | const XMLNamespaces_t * | ns, |
const char * | prefix | ||
) |
Look up the index of an XML namespace declaration by prefix
.
ns | the XMLNamespaces_t structure. |
prefix | a string, prefix of the required namespace. |
-1
if not present. LIBLAX_EXTERN int XMLNamespaces_getLength | ( | const XMLNamespaces_t * | ns | ) |
Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces_t instance.
ns | the XMLNamespaces_t structure. |
LIBLAX_EXTERN int XMLNamespaces_getNumNamespaces | ( | const XMLNamespaces_t * | ns | ) |
Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces_t instance.
This function is an alias for getLength introduced for consistency with other XML classes.
ns | the XMLNamespaces_t structure. |
LIBLAX_EXTERN char * XMLNamespaces_getPrefix | ( | const XMLNamespaces_t * | ns, |
int | index | ||
) |
Look up the prefix of an XML namespace declaration by its position.
An XMLNamespaces_t structure 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.
ns | the XMLNamespaces_t structure. |
index | an integer, position of the sought-after prefix. |
index
is out of rangeLIBLAX_EXTERN char * XMLNamespaces_getPrefixByURI | ( | const XMLNamespaces_t * | ns, |
const char * | uri | ||
) |
Look up the prefix of an XML namespace declaration by its URI.
An XMLNamespaces_t structure stores a list of pairs of namespaces and their prefixes. This method returns the prefix for a pair that has the given uri
.
ns | the XMLNamespaces_t structure. |
uri | a string, the URI of the prefix being sought. |
uri
exists in this XMLNamespaces_t structure LIBLAX_EXTERN char * XMLNamespaces_getURI | ( | const XMLNamespaces_t * | ns, |
int | index | ||
) |
Look up the URI of an XML namespace declaration by its position.
An XMLNamespaces_t structure 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.
ns | the XMLNamespaces_t structure. |
index | an integer, position of the required URI. |
index
is out of range.LIBLAX_EXTERN char * XMLNamespaces_getURIByPrefix | ( | const XMLNamespaces_t * | ns, |
const char * | prefix | ||
) |
Look up the URI of an XML namespace declaration by its prefix.
An XMLNamespaces_t 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
.
ns | the XMLNamespaces_t structure. |
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_t objectLIBLAX_EXTERN int XMLNamespaces_hasNS | ( | const XMLNamespaces_t * | ns, |
const char * | uri, | ||
const char * | prefix | ||
) |
Predicate returning 1
(true) or 0
(false) depending on whether an XML Namespace with the given URI is contained in this XMLNamespaces_t list.
1
(true) if an XML Namespace with the given uri/prefix pair is contained in this XMLNamespaces_t list, 0
(false) otherwise. LIBLAX_EXTERN int XMLNamespaces_hasPrefix | ( | const XMLNamespaces_t * | ns, |
const char * | prefix | ||
) |
Predicate returning 1
(true) or 0
(false) depending on whether an XML Namespace the given prefix
is contained in this XMLNamespaces_t list.
1
(true) if an XML Namespace with the given URI is contained in this XMLNamespaces_t list, 0
(false) otherwise. LIBLAX_EXTERN int XMLNamespaces_hasURI | ( | const XMLNamespaces_t * | ns, |
const char * | uri | ||
) |
Predicate returning 1
(true) or 0
(false) depending on whether an XML Namespace with the given URI is contained in this XMLNamespaces_t list.
1
(true) if an XML Namespace with the given URI is contained in this XMLNamespaces_t list, 0
(false) otherwise. LIBLAX_EXTERN int XMLNamespaces_isEmpty | ( | const XMLNamespaces_t * | ns | ) |
Predicate returning 1
(true) or 0
(false) depending on whether this XMLNamespaces_t list is empty.
1
(true) if this XMLNamespaces_t list is empty, 0
(false) otherwise. LIBLAX_EXTERN int XMLNamespaces_remove | ( | XMLNamespaces_t * | ns, |
int | index | ||
) |
Removes an XML Namespace stored in the given position of this list.
ns | XMLNamespaces_t structure. |
index | an integer, position of the removed namespace. |
LIBLAX_EXTERN int XMLNamespaces_removeByPrefix | ( | XMLNamespaces_t * | ns, |
const char * | prefix | ||
) |
Removes an XML Namespace with the given prefix
.
ns | XMLNamespaces_t structure. |
prefix | a string, prefix of the required namespace. |