/**
* @return
*/
private Document generateCapabilitiesDocument() {
Document doc;
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
DOMImplementation impl = builder.getDOMImplementation();
DocumentType doctype = impl.createDocumentType("wms", "WMT_MS_Capabilities",
"http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd");
doc = impl.createDocument(null, "WMT_MS_Capabilities", doctype);
} catch (javax.xml.parsers.ParserConfigurationException ex) {
throw new RuntimeException("Cannot create new Xml Document:" + ex.getMessage());
}
Element root = doc.getDocumentElement();
root.setAttribute("version", "1.1.1");
root.setAttribute("updateSequence", Integer.toString(updateSequence));
Element service = doc.createElement("Service");
service.appendChild(textnode(doc, "Name", "OGC:WMS"));
service.appendChild(textnode(doc, "Title", wmsTitle));
service.appendChild(textnode(doc, "Abstract", wmsAbstract));
if (!keywordsList.isEmpty()) {
Element keywordListElement = doc.createElement("KeywordList");
for (int i = 0; i < keywordsList.size(); i++) {
keywordListElement.appendChild(textnode(doc, "Keyword", (String) keywordsList.get(i)));
}
service.appendChild(keywordListElement);
}
Element onlineResource = doc.createElement("OnlineResource");
onlineResource.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
onlineResource.setAttribute("xlink:type", "simple");
onlineResource.setAttribute("xlink:href", onlineResourcesList[FMT_MAIN]);
service.appendChild(onlineResource);
service.appendChild(textnode(doc, "Fees", "none"));
service.appendChild(textnode(doc, "AccessConstraints", "none"));
root.appendChild(service);
Node capability = doc.createElement("Capability");
Element request = doc.createElement("Request");
request.appendChild(requestcap(doc, WMTConstants.GETCAPABILITIES, formatsList[FMT_GETCAPS], "Get",
onlineResourcesList[FMT_GETCAPS]));
request.appendChild(requestcap(doc, WMTConstants.GETMAP, formatsList[FMT_GETMAP], "Get",
onlineResourcesList[FMT_GETMAP]));
request.appendChild(requestcap(doc, WMTConstants.GETFEATUREINFO, formatsList[FMT_GETFEATUREINFO],
"Get", onlineResourcesList[FMT_GETFEATUREINFO]));
capability.appendChild(request);
Element exceptionElement = doc.createElement("Exception");
for (int i = 0; i < formatsList[FMT_EXCEPTIONS].size(); i++) {
exceptionElement.appendChild(textnode(doc, "Format", (String) formatsList[FMT_EXCEPTIONS].get(i)));
}
capability.appendChild(exceptionElement);