javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
InputSource input = new InputSource(xml);
org.w3c.dom.Document dom = db.parse(input);
SLDParser sldParser = new SLDParser(styleFactory);
Node rootNode = dom.getDocumentElement();
// we have the SLD component, now we get all the GetMAp components
// step a -- attribute "version"
Node nodeGetMap = rootNode;
if (!(nodeNameEqual(nodeGetMap, "getmap"))) {
if (nodeNameEqual(nodeGetMap, "StyledLayerDescriptor")) // oopsy!! its a SLD POST
// with get parameters!
{
if (validateSchema) {
validateSchemaSLD(temp, getMapRequest);
}
handlePostGet(rootNode, sldParser, getMapRequest);
return;
}
throw new Exception(
"GetMap XML parser - start node isnt 'GetMap' or 'StyledLayerDescriptor' tag");
}
if (validateSchema) {
validateSchemaGETMAP(temp, getMapRequest);
}
NamedNodeMap atts = nodeGetMap.getAttributes();
Node wmsVersion = atts.getNamedItem("version");
if (wmsVersion == null) {
throw new Exception(
"GetMap XML parser - couldnt find attribute 'version' in GetMap tag");
}
getMapRequest.setVersion(wmsVersion.getNodeValue());
// ignore the OWSType since we know its supposed to be WMS
// step b -bounding box
parseBBox(getMapRequest, nodeGetMap);
// for SLD we already have it (from above) (which we'll handle as layers later)
StyledLayerDescriptor sld = sldParser.parseDescriptor(getNode(rootNode,
"StyledLayerDescriptor"));
processStyles(getMapRequest, sld);
// step c - "Output"
parseXMLOutput(nodeGetMap, getMapRequest); // make this function easier to read