{core}
Interface to an XML output stream.
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.
SBML content is serialized using XML; the resulting data can be stored and read to/from a file or data stream. Low-level XML parsers such as Xerces provide facilities to read XML data. To permit the use of different XML parsers (Xerces, Expat or libxml2), libSBML implements an abstraction layer. XMLInputStream and XMLOutputStream are two parts of that abstraction layer.
XMLOutputStream provides a wrapper above output streams to facilitate writing XML. XMLOutputStream keeps track of start and end elements, indentation, XML namespace prefixes, and more. The interface provides features for converting non-text data types into appropriate textual form; this takes the form of overloaded writeAttribute(...)
methods that allow users to simply use the same method with any data type. For example, suppose an element testElement
has two attributes, size
and id
, and the attributes are variables in your code as follows: Then, the element and the attributes can be written to the standard output stream (provided as cout
in the libSBML language bindings)as follows:
Other classes in SBML take XMLOutputStream objects as arguments, and use that to write elements and attributes seamlessly to the XML output stream.
It is also worth noting that unlike XMLInputStream, XMLOutputStream is actually independent of the underlying XML parsers. It does not use the XML parser libraries at all.
- Note
- The convenience of the XMLInputStream and XMLOutputStream abstraction may be useful for developers interested in creating parsers for other XML formats besides SBML. It can provide developers with a layer above more basic XML parsers, as well as some useful programmatic elements such as XMLToken, XMLError, etc.
- See also
- XMLInputStream
|
virtual void | Dispose () |
|
void | downIndent () |
| Decreases the indentation level for this XMLOutputStream. More...
|
|
void | endElement (string name, string prefix) |
| Writes the given XML end element name to this XMLOutputStream. More...
|
|
void | endElement (string name) |
| Writes the given XML end element name to this XMLOutputStream. More...
|
|
void | endElement (XMLTriple triple) |
| Writes the given element to the stream. More...
|
|
override bool | Equals (Object sb) |
|
override int | GetHashCode () |
|
SBMLNamespaces | getSBMLNamespaces () |
| Returns the SBMLNamespaces object attached to this output stream. More...
|
|
void | setAutoIndent (bool indent) |
| Turns automatic indentation on or off for this XMLOutputStream. More...
|
|
void | setSBMLNamespaces (SBMLNamespaces sbmlns) |
| Sets the SBMLNamespaces object associated with this output stream. More...
|
|
void | startElement (string name, string prefix) |
| Writes the given XML start element name to this XMLOutputStream. More...
|
|
void | startElement (string name) |
| Writes the given XML start element name to this XMLOutputStream. More...
|
|
void | startElement (XMLTriple triple) |
| Writes the given XML start element. More...
|
|
void | startEndElement (string name, string prefix) |
| Writes the given XML start and end element name to this XMLOutputStream. More...
|
|
void | startEndElement (string name) |
| Writes the given XML start and end element name to this XMLOutputStream. More...
|
|
void | startEndElement (XMLTriple triple) |
| Writes the given start element to this output stream. More...
|
|
void | upIndent () |
| Increases the indentation level for this XMLOutputStream. More...
|
|
void | writeAttribute (string name, string value) |
| Writes the given attribute and value to this output stream. More...
|
|
void | writeAttribute (string name, string prefix, string value) |
| Writes the given namespace-prefixed attribute value to this output stream. More...
|
|
void | writeAttribute (XMLTriple triple, string value) |
| Writes the given attribute and value to this output stream. More...
|
|
void | writeAttribute (string name, bool value) |
| Writes the given attribute and value to this output stream. More...
|
|
void | writeAttribute (string name, string prefix, bool value) |
| Writes the given namespace-prefixed attribute value to this output stream. More...
|
|
void | writeAttribute (XMLTriple triple, bool value) |
| Writes the given attribute and value to this output stream. More...
|
|
void | writeAttribute (string name, double value) |
| Writes the given attribute and value to this output stream. More...
|
|
void | writeAttribute (string name, string prefix, double value) |
| Writes the given namespace-prefixed attribute value to this output stream. More...
|
|
void | writeAttribute (XMLTriple triple, double value) |
| Writes the given attribute and value to this output stream. More...
|
|
void | writeAttribute (string name, int value) |
| Writes the given attribute and value to this output stream. More...
|
|
void | writeAttribute (string name, string prefix, int value) |
| Writes the given namespace-prefixed attribute value to this output stream. More...
|
|
void | writeAttribute (XMLTriple triple, int value) |
| Writes the given attribute and value to this output stream. More...
|
|
void | writeAttribute (string name, string prefix, long value) |
| Writes the given namespace-prefixed attribute value to this output stream. More...
|
|
void | writeComment (string programName, string programVersion, bool writeTimestamp) |
| Writes an XML comment with the name and version of this program. More...
|
|
void | writeComment (string programName, string programVersion) |
| Writes an XML comment with the name and version of this program. More...
|
|
void | writeXMLDecl () |
| Writes a standard XML declaration to this output stream. More...
|
|
| XMLOutputStream (OStream stream, string encoding, bool writeXMLDecl, string programName, string programVersion) |
| Creates a new XMLOutputStream that wraps the given stream . More...
|
|
| XMLOutputStream (OStream stream, string encoding, bool writeXMLDecl, string programName) |
| Creates a new XMLOutputStream that wraps the given stream . More...
|
|
| XMLOutputStream (OStream stream, string encoding, bool writeXMLDecl) |
| Creates a new XMLOutputStream that wraps the given stream . More...
|
|
| XMLOutputStream (OStream stream, string encoding) |
| Creates a new XMLOutputStream that wraps the given stream . More...
|
|
| XMLOutputStream (OStream stream) |
| Creates a new XMLOutputStream that wraps the given stream . More...
|
|
libsbmlcs.XMLOutputStream.XMLOutputStream |
( |
OStream |
stream, |
|
|
string |
encoding, |
|
|
bool |
writeXMLDecl, |
|
|
string |
programName, |
|
|
string |
programVersion |
|
) |
| |
Creates a new XMLOutputStream that wraps the given stream
.
The functionality associated with the programName
and programVersion
arguments concerns an optional comment that libSBML can write at the beginning of the output stream. The comment is intended for human readers of the XML file, and has the following form:
<!-- Created by <program name> version <program version>
on yyyy-MM-dd HH:mm with libSBML version <libsbml version>. -->
This program information comment is a separate item from the XML declaration that this method can also write to this output stream. The comment is also not mandated by any SBML specification. This libSBML functionality is provided for the convenience of calling programs, and to help humans trace the origin of SBML files.
The XML declaration has the form
<?xml version='1.0' encoding='UTF-8'?>
Note that the SBML specifications require the use of UTF-8 encoding and version 1.0, so for SBML documents, the above is the standard XML declaration.
- Parameters
-
stream | the input stream to wrap. |
encoding | the XML encoding to declare in the output. This value should be 'UTF-8' for SBML documents. The default value is 'UTF-8' if no value is supplied for this parameter. |
writeXMLDecl | whether to write a standard XML declaration at the beginning of the content written on stream . The default is true . |
programName | an optional program name to write as a comment in the output stream. |
programVersion | an optional version identification string to write as a comment in the output stream. |
- 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.
libsbmlcs.XMLOutputStream.XMLOutputStream |
( |
OStream |
stream, |
|
|
string |
encoding, |
|
|
bool |
writeXMLDecl, |
|
|
string |
programName |
|
) |
| |
Creates a new XMLOutputStream that wraps the given stream
.
The functionality associated with the programName
and programVersion
arguments concerns an optional comment that libSBML can write at the beginning of the output stream. The comment is intended for human readers of the XML file, and has the following form:
<!-- Created by <program name> version <program version>
on yyyy-MM-dd HH:mm with libSBML version <libsbml version>. -->
This program information comment is a separate item from the XML declaration that this method can also write to this output stream. The comment is also not mandated by any SBML specification. This libSBML functionality is provided for the convenience of calling programs, and to help humans trace the origin of SBML files.
The XML declaration has the form
<?xml version='1.0' encoding='UTF-8'?>
Note that the SBML specifications require the use of UTF-8 encoding and version 1.0, so for SBML documents, the above is the standard XML declaration.
- Parameters
-
stream | the input stream to wrap. |
encoding | the XML encoding to declare in the output. This value should be 'UTF-8' for SBML documents. The default value is 'UTF-8' if no value is supplied for this parameter. |
writeXMLDecl | whether to write a standard XML declaration at the beginning of the content written on stream . The default is true . |
programName | an optional program name to write as a comment in the output stream. |
programVersion | an optional version identification string to write as a comment in the output stream. |
- 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.
libsbmlcs.XMLOutputStream.XMLOutputStream |
( |
OStream |
stream, |
|
|
string |
encoding, |
|
|
bool |
writeXMLDecl |
|
) |
| |
Creates a new XMLOutputStream that wraps the given stream
.
The functionality associated with the programName
and programVersion
arguments concerns an optional comment that libSBML can write at the beginning of the output stream. The comment is intended for human readers of the XML file, and has the following form:
<!-- Created by <program name> version <program version>
on yyyy-MM-dd HH:mm with libSBML version <libsbml version>. -->
This program information comment is a separate item from the XML declaration that this method can also write to this output stream. The comment is also not mandated by any SBML specification. This libSBML functionality is provided for the convenience of calling programs, and to help humans trace the origin of SBML files.
The XML declaration has the form
<?xml version='1.0' encoding='UTF-8'?>
Note that the SBML specifications require the use of UTF-8 encoding and version 1.0, so for SBML documents, the above is the standard XML declaration.
- Parameters
-
stream | the input stream to wrap. |
encoding | the XML encoding to declare in the output. This value should be 'UTF-8' for SBML documents. The default value is 'UTF-8' if no value is supplied for this parameter. |
writeXMLDecl | whether to write a standard XML declaration at the beginning of the content written on stream . The default is true . |
programName | an optional program name to write as a comment in the output stream. |
programVersion | an optional version identification string to write as a comment in the output stream. |
- 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.
libsbmlcs.XMLOutputStream.XMLOutputStream |
( |
OStream |
stream, |
|
|
string |
encoding |
|
) |
| |
Creates a new XMLOutputStream that wraps the given stream
.
The functionality associated with the programName
and programVersion
arguments concerns an optional comment that libSBML can write at the beginning of the output stream. The comment is intended for human readers of the XML file, and has the following form:
<!-- Created by <program name> version <program version>
on yyyy-MM-dd HH:mm with libSBML version <libsbml version>. -->
This program information comment is a separate item from the XML declaration that this method can also write to this output stream. The comment is also not mandated by any SBML specification. This libSBML functionality is provided for the convenience of calling programs, and to help humans trace the origin of SBML files.
The XML declaration has the form
<?xml version='1.0' encoding='UTF-8'?>
Note that the SBML specifications require the use of UTF-8 encoding and version 1.0, so for SBML documents, the above is the standard XML declaration.
- Parameters
-
stream | the input stream to wrap. |
encoding | the XML encoding to declare in the output. This value should be 'UTF-8' for SBML documents. The default value is 'UTF-8' if no value is supplied for this parameter. |
writeXMLDecl | whether to write a standard XML declaration at the beginning of the content written on stream . The default is true . |
programName | an optional program name to write as a comment in the output stream. |
programVersion | an optional version identification string to write as a comment in the output stream. |
- 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.
libsbmlcs.XMLOutputStream.XMLOutputStream |
( |
OStream |
stream | ) |
|
Creates a new XMLOutputStream that wraps the given stream
.
The functionality associated with the programName
and programVersion
arguments concerns an optional comment that libSBML can write at the beginning of the output stream. The comment is intended for human readers of the XML file, and has the following form:
<!-- Created by <program name> version <program version>
on yyyy-MM-dd HH:mm with libSBML version <libsbml version>. -->
This program information comment is a separate item from the XML declaration that this method can also write to this output stream. The comment is also not mandated by any SBML specification. This libSBML functionality is provided for the convenience of calling programs, and to help humans trace the origin of SBML files.
The XML declaration has the form
<?xml version='1.0' encoding='UTF-8'?>
Note that the SBML specifications require the use of UTF-8 encoding and version 1.0, so for SBML documents, the above is the standard XML declaration.
- Parameters
-
stream | the input stream to wrap. |
encoding | the XML encoding to declare in the output. This value should be 'UTF-8' for SBML documents. The default value is 'UTF-8' if no value is supplied for this parameter. |
writeXMLDecl | whether to write a standard XML declaration at the beginning of the content written on stream . The default is true . |
programName | an optional program name to write as a comment in the output stream. |
programVersion | an optional version identification string to write as a comment in the output stream. |
- 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.