VersionFinder { public static String findVersion(Document doc) { String foundVersion = WMService.WMS_1_1_1; Node simpleXPath = XMLTools.simpleXPath(doc, "WMT_MS_Capabilities"); if (simpleXPath != null) { NamedNodeMap attributes = simpleXPath.getAttributes(); Node namedItem = attributes.getNamedItem("version"); if (WMService.WMS_1_1_1.equals(namedItem.getNodeValue()) || WMService.WMS_1_1_0.equals(namedItem.getNodeValue())) { foundVersion = WMService.WMS_1_1_1; } else { foundVersion = WMService.WMS_1_0_0; } } simpleXPath = XMLTools.simpleXPath(doc, "WMS_Capabilities"); if (simpleXPath != null) { NamedNodeMap attributes = simpleXPath.getAttributes(); Node namedItem = attributes.getNamedItem("version"); if (WMService.WMS_1_3_0.equals(namedItem.getNodeValue())) { foundVersion = WMService.WMS_1_3_0; } } return foundVersion; } VersionFinder(); static String findVersion(Document doc);  }
@Test public void testFindVersion_1_3_0() throws Exception { Document doc = getDocument(CAPABILITIES_1_3_0); String vers = VersionFinder.findVersion(doc); assertTrue(WMService.WMS_1_3_0.equals(vers)); }