* @param gmlGraph Graph model.
* @return The Xml document generated.
*/
public static Document encodeXML(mxGmlGraph gmlGraph)
{
Document doc = new DocumentImpl();
Element graphml = doc.createElement(mxGmlConstants.GRAPHML);
graphml.setAttribute("xmlns", "http://graphml.graphdrawing.org/xmlns");
graphml.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance");
graphml.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:jGraph",
mxGmlConstants.JGRAPH_URL);
graphml.setAttributeNS(
"http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation",
"http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd");
HashMap<String, mxGmlKey> keyMap = mxGmlKeyManager.getInstance()
.getKeyMap();
for (mxGmlKey key : keyMap.values())
{
Element keyElement = key.generateElement(doc);
graphml.appendChild(keyElement);
}
Element graphE = gmlGraph.generateElement(doc);
graphml.appendChild(graphE);
doc.appendChild(graphml);
cleanMaps();
return doc;
}