libSBML C# API  5.18.0
libsbmlcs.XMLNamespaces Class Reference
Inheritance diagram for libsbmlcs.XMLNamespaces:
[legend]

Detailed Description

An XML Namespace.

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(int index), or by their characteristics such as their URI or position in the list.

Public Member Functions

int add (string uri, string prefix)
 Appends an XML namespace prefix and URI pair to this list of namespace declarations. More...
 
int add (string uri)
 Appends an XML namespace prefix and URI pair to this list of namespace declarations. More...
 
int clear ()
 Clears (deletes) all XML namespace declarations in this XMLNamespaces object. More...
 
XMLNamespaces clone ()
 Creates and returns a deep copy of this XMLNamespaces object. More...
 
bool containsUri (string uri)
 Tests whether the given uri is contained in this set of namespaces. More...
 
virtual void Dispose ()
 
override bool Equals (Object sb)
 
override int GetHashCode ()
 
int getIndex (string uri)
 Look up the index of an XML namespace declaration by URI. More...
 
int getIndexByPrefix (string prefix)
 Look up the index of an XML namespace declaration by prefix. More...
 
int getLength ()
 Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces instance. More...
 
int getNumNamespaces ()
 Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces instance. More...
 
string getPrefix (int index)
 Look up the prefix of an XML namespace declaration by its position. More...
 
string getPrefix (string uri)
 Look up the prefix of an XML namespace declaration by its URI. More...
 
string getURI (int index)
 Look up the URI of an XML namespace declaration by its position. More...
 
string getURI (string prefix)
 Look up the URI of an XML namespace declaration by its prefix. More...
 
string getURI ()
 Look up the URI of an XML namespace declaration by its prefix. More...
 
bool hasNS (string uri, string 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...
 
bool hasPrefix (string prefix)
 Predicate returning true or false depending on whether an XML Namespace with the given prefix is contained in this XMLNamespaces list. More...
 
bool hasURI (string uri)
 Predicate returning true or false depending on whether an XML Namespace with the given URI is contained in this XMLNamespaces list. More...
 
bool isEmpty ()
 Predicate returning true or false depending on whether this XMLNamespaces list is empty. More...
 
int remove (int index)
 Removes an XML Namespace stored in the given position of this list. More...
 
int remove (string prefix)
 Removes an XML Namespace with the given prefix. More...
 
 XMLNamespaces ()
 Creates a new empty list of XML namespace declarations. More...
 
 XMLNamespaces (XMLNamespaces orig)
 Copy constructor; creates a copy of this XMLNamespaces list. More...
 

Static Public Member Functions

static bool operator!= (XMLNamespaces lhs, XMLNamespaces rhs)
 
static bool operator== (XMLNamespaces lhs, XMLNamespaces rhs)
 

Protected Attributes

bool swigCMemOwn
 

Constructor & Destructor Documentation

libsbmlcs.XMLNamespaces.XMLNamespaces ( )

Creates a new empty list of XML namespace declarations.

libsbmlcs.XMLNamespaces.XMLNamespaces ( XMLNamespaces  orig)

Copy constructor; creates a copy of this XMLNamespaces list.

Parameters
origthe XMLNamespaces object to copy.

Member Function Documentation

int libsbmlcs.XMLNamespaces.add ( string  uri,
string  prefix 
)

Appends an XML namespace prefix and URI pair to this list of namespace declarations.

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.

Parameters
uria string, the uri for the namespace.
prefixa string, the prefix for the namespace.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.
int libsbmlcs.XMLNamespaces.add ( string  uri)

Appends an XML namespace prefix and URI pair to this list of namespace declarations.

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.

Parameters
uria string, the uri for the namespace.
prefixa string, the prefix for the namespace.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.
int libsbmlcs.XMLNamespaces.clear ( )

Clears (deletes) all XML namespace declarations in this XMLNamespaces object.

Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
See also
remove(int index)
XMLNamespaces libsbmlcs.XMLNamespaces.clone ( )

Creates and returns a deep copy of this XMLNamespaces object.

Returns
the (deep) copy of this XMLNamespaces object.
bool libsbmlcs.XMLNamespaces.containsUri ( string  uri)

Tests whether the given uri is contained in this set of namespaces.

virtual void libsbmlcs.XMLNamespaces.Dispose ( )
virtual
override bool libsbmlcs.XMLNamespaces.Equals ( Object  sb)
override int libsbmlcs.XMLNamespaces.GetHashCode ( )
int libsbmlcs.XMLNamespaces.getIndex ( string  uri)

Look up the index of an XML namespace declaration by URI.

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.

Parameters
uria string, the URI of the sought-after namespace.
Returns
the index of the given declaration, or -1 if not present.
int libsbmlcs.XMLNamespaces.getIndexByPrefix ( string  prefix)

Look up the index of an XML namespace declaration by prefix.

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.

Parameters
prefixa string, the prefix string of the sought-after namespace.
Returns
the index of the given declaration, or -1 if not present.
int libsbmlcs.XMLNamespaces.getLength ( )

Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces instance.

Returns
the number of namespaces in this list.
int libsbmlcs.XMLNamespaces.getNumNamespaces ( )

Returns the total number of URI-and-prefix pairs stored in this particular XMLNamespaces instance.

Returns
the number of namespaces in this list.

This function is an alias for getLength introduced for consistency with other XML classes.

string libsbmlcs.XMLNamespaces.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 nth element in that list (if it exists). Callers should use XMLAttributes::getLength() first to find out how many namespaces are stored in the list.

Parameters
indexan integer, position of the sought-after prefix.
Returns
the prefix of an XML namespace declaration in this list (by position), or an empty string if the index is out of range.
See also
getLength()
string libsbmlcs.XMLNamespaces.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.

Parameters
uria string, the URI of the prefix being sought.
Returns
the prefix of an XML namespace declaration given its URI, or an empty string if no such uri exists in this XMLNamespaces object.
string libsbmlcs.XMLNamespaces.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 nth element in that list (if it exists). Callers should use XMLAttributes::getLength() first to find out how many namespaces are stored in the list.

Parameters
indexan integer, position of the required URI.
Returns
the URI of an XML namespace declaration in this list (by position), or an empty string if the index is out of range.
See also
getLength()
string libsbmlcs.XMLNamespaces.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.

Parameters
prefixa string, the prefix of the required URI.
Returns
the URI of an XML namespace declaration having the given prefix, or an empty string if no such prefix-and-URI pair exists in this XMLNamespaces object.
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.
See also
getURI()
string libsbmlcs.XMLNamespaces.getURI ( )

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.

Parameters
prefixa string, the prefix of the required URI.
Returns
the URI of an XML namespace declaration having the given prefix, or an empty string if no such prefix-and-URI pair exists in this XMLNamespaces object.
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.
See also
getURI()
bool libsbmlcs.XMLNamespaces.hasNS ( string  uri,
string  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.

Parameters
uria string, the URI for the namespace.
prefixa string, the prefix for the namespace.
Returns
true if an XML Namespace with the given uri/prefix pair is contained in this XMLNamespaces list, false otherwise.
bool libsbmlcs.XMLNamespaces.hasPrefix ( string  prefix)

Predicate returning true or false depending on whether an XML Namespace with the given prefix is contained in this XMLNamespaces list.

Parameters
prefixa string, the prefix for the namespace.
Returns
true if an XML Namespace with the given URI is contained in this XMLNamespaces list, false otherwise.
bool libsbmlcs.XMLNamespaces.hasURI ( string  uri)

Predicate returning true or false depending on whether an XML Namespace with the given URI is contained in this XMLNamespaces list.

Parameters
uria string, the uri for the namespace.
Returns
true if an XML Namespace with the given URI is contained in this XMLNamespaces list, false otherwise.
bool libsbmlcs.XMLNamespaces.isEmpty ( )

Predicate returning true or false depending on whether this XMLNamespaces list is empty.

Returns
true if this XMLNamespaces list is empty, false otherwise.
static bool libsbmlcs.XMLNamespaces.operator!= ( XMLNamespaces  lhs,
XMLNamespaces  rhs 
)
static
static bool libsbmlcs.XMLNamespaces.operator== ( XMLNamespaces  lhs,
XMLNamespaces  rhs 
)
static
int libsbmlcs.XMLNamespaces.remove ( int  index)

Removes an XML Namespace stored in the given position of this list.

Parameters
indexan integer, position of the namespace to remove.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
int libsbmlcs.XMLNamespaces.remove ( string  prefix)

Removes an XML Namespace with the given prefix.

Parameters
prefixa string, prefix of the required namespace.
Returns
integer value indicating success/failure of the function. The possible values returned by this function are:
See also
remove(int index)

Member Data Documentation

bool libsbmlcs.XMLNamespaces.swigCMemOwn
protected