/**
* @see edu.indiana.extreme.xbaya.graph.Graph#toXML()
*/
public XmlElement toXML() {
XmlElement graphElement = XMLUtil.BUILDER.newFragment(GraphSchema.NS,
GraphSchema.GRAPH_TAG);
graphElement.setAttributeValue(GraphSchema.NS,
GraphSchema.XBAYA_VERSION_ATTRIBUTE, XBayaVersion.VERSION);
XmlElement idElement = graphElement.addElement(GraphSchema.NS,
GraphSchema.GRAPH_ID_TAG);
idElement.addChild(getID());
if (this.name != null) {
XmlElement nameElement = graphElement.addElement(GraphSchema.NS,
GraphSchema.GRAPH_NAME_TAG);
nameElement.addChild(getName());
}
if (this.description != null) {
XmlElement descriptionElement = graphElement.addElement(
GraphSchema.NS, GraphSchema.GRAPH_DESCRIPTION_TAG);
descriptionElement.addChild(getDescription());
}
toXML(graphElement);
for (NodeImpl node : this.nodes) {
XmlElement nodeElement = node.toXML();
graphElement.addChild(nodeElement);
}
for (PortImpl port : this.ports) {
XmlElement portElement = port.toXML();
graphElement.addChild(portElement);
}
for (EdgeImpl edge : this.edges) {
XmlElement edgeElement = edge.toXML();
graphElement.addChild(edgeElement);
}
return graphElement;
}