&& (programVersion.length() > 0) ? programVersion
: "?", date, JSBML.getJSBMLDottedVersion()));
outputDocument.addCharacters("\n");
}
SMOutputElement smOutputElement = outputDocument.addElement(namespace,
sbmlDocument.getElementName());
SBMLObjectForXML xmlObject = new SBMLObjectForXML();
xmlObject.setName(sbmlDocument.getElementName());
xmlObject.setNamespace(SBMLNamespace);
xmlObject.addAttributes(sbmlDocument.writeXMLAttributes());
// register all the name spaces of the SBMLDocument to the writer
Iterator<Map.Entry<String, String>> it = sbmlDocument
.getSBMLDocumentNamespaces().entrySet().iterator();
logger.debug(" SBML name spaces size = "
+ sbmlDocument.getSBMLDocumentNamespaces().size());
while (it.hasNext()) {
Map.Entry<String, String> entry = it.next();
if (!entry.getKey().equals("xmlns")) {
logger.debug(" SBML name spaces : " + entry.getKey() + " = "
+ entry.getValue());
String namespacePrefix = entry.getKey().substring(
entry.getKey().indexOf(":") + 1);
streamWriter.setPrefix(namespacePrefix, entry.getValue());
logger.debug(" SBML namespaces : " + namespacePrefix + " = "
+ entry.getValue());
}
}
it = xmlObject.getAttributes().entrySet().iterator();
while (it.hasNext()) {
Entry<String, String> entry = it.next();
smOutputElement.addAttribute(entry.getKey(), entry.getValue());
}
int indent = indentCount;
if (sbmlDocument.isSetNotes()) {
writeNotes(sbmlDocument, smOutputElement, streamWriter,
SBMLNamespace, indent);
}
if (sbmlDocument.isSetAnnotation()) {
writeAnnotation(sbmlDocument, smOutputElement, streamWriter,
indent, false);
}
smOutputElement.addCharacters("\n");
writeSBMLElements(xmlObject, smOutputElement, streamWriter,
sbmlDocument, indent);
outputDocument.closeRoot();