Mercurial > mxd2map
diff src/java/de/intevation/mxd/utils/MapToXMLUtils.java @ 38:27577294f9ca
Added root element to document and save the filename in the XML tree.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 14 Apr 2011 11:04:59 +0200 |
parents | 7a927921eb6c |
children | ef7ca23c4233 |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/utils/MapToXMLUtils.java Wed Apr 13 16:38:03 2011 +0200 +++ b/src/java/de/intevation/mxd/utils/MapToXMLUtils.java Thu Apr 14 11:04:59 2011 +0200 @@ -21,11 +21,21 @@ public class MapToXMLUtils { private Document root; + private Element rootElement; private XMLUtils.ElementCreator creator; public MapToXMLUtils() { this.root = XMLUtils.newDocument(); creator = new XMLUtils.ElementCreator(root, "", ""); + rootElement = creator.create("mxd"); + root.appendChild(rootElement); + } + + public boolean addFilename(String path) { + Element file = creator.create("file"); + file.setAttribute("name", path); + rootElement.appendChild(file); + return true; } /** @@ -39,7 +49,7 @@ NodeList list = root.getElementsByTagName("map"); if(list == null || list.getLength() == 0){ map = creator.create("map"); - root.appendChild(map); + rootElement.appendChild(map); } else if(list.getLength() == 1){ map = (Element)list.item(0); @@ -100,4 +110,8 @@ public void print() { XMLUtils.toStream(root, System.out); } + + public Document getDocument() { + return root; + } }