private static void removeWhitespaceInner(Node n, Node parent) { // This n is removed from the parent if n is a whitespace node if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) { Text t = (Text) n; if (t.getData().matches("[ \t\n]*")) { parent.removeChild(t); } } if (n.hasChildNodes()) { int length = n.getChildNodes().getLength(); List<Node> toBeProcessed = new ArrayList<Node>(); // We collect all the nodes to iterate as the child nodes will change // upon removal for (int i = 0; i < length; i++) { toBeProcessed.add(n.getChildNodes().item(i)); } // This changes the child nodes, but the iterator of nodes never changes // meaning that this is safe for (Node childNode : toBeProcessed) { removeWhitespaceInner(childNode, n); } } }
private static void removeWhitespaceInner(Node n, Node parent) { // This n is removed from the parent if n is a whitespace node if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) { Text t = (Text) n; if (t.getData().matches("[ \t\n]*")) { parent.removeChild(t); } } if (n.hasChildNodes()) { int length = n.getChildNodes().getLength(); List<Node> toBeProcessed = new ArrayList<Node>(); // We collect all the nodes to iterate as the child nodes will change // upon removal for (int i = 0; i < length; i++) { toBeProcessed.add(n.getChildNodes().item(i)); } // This changes the child nodes, but the iterator of nodes never changes // meaning that this is safe for (Node childNode : toBeProcessed) { removeWhitespaceInner(childNode, n); } } }
private static void removeWhitespaceInner(Node n, Node parent) { // This n is removed from the parent if n is a whitespace node if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) { Text t = (Text) n; if (t.getData().matches("[ \t\n]*")) { parent.removeChild(t); } } if (n.hasChildNodes()) { int length = n.getChildNodes().getLength(); List<Node> toBeProcessed = new ArrayList<Node>(); // We collect all the nodes to iterate as the child nodes will change // upon removal for (int i = 0; i < length; i++) { toBeProcessed.add(n.getChildNodes().item(i)); } // This changes the child nodes, but the iterator of nodes never changes // meaning that this is safe for (Node childNode : toBeProcessed) { removeWhitespaceInner(childNode, n); } } }
protected void parse(Node node) { NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); String nodeName = child.getNodeName(); if ("Name".equalsIgnoreCase(nodeName)) { name = getValueRecursive(child); } else if ("Title".equalsIgnoreCase(nodeName)) { title = getValueRecursive(child); } else if ("Abstract".equalsIgnoreCase(nodeName)) { abstractt = getValueRecursive(child); } else if ("LegendURL".equalsIgnoreCase(nodeName)) { legendUrl = createLegendInfo(child); } } }
public static String getXmlNodeValue(Node node) { if (node.getNodeType() != Node.ELEMENT_NODE) { return null; } String ret = ""; NodeList textNodes = node.getChildNodes(); for (int i = 0; i < textNodes.getLength(); i++) { Node n = textNodes.item(i); if (n.getNodeType() == Node.TEXT_NODE && n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0) { ret += n.getNodeValue(); } else if (n.getNodeType() == Node.CDATA_SECTION_NODE) { ret += n.getNodeValue(); } } return ret.length() == 0 ? null : ret.replaceAll("^\\s+", "").replaceAll("\\s+$", ""); }
protected void parse(Node node) { parsed = true; NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); String nodeName = child.getNodeName(); if ("Name".equalsIgnoreCase(nodeName)) { name = getValueRecursive(child); } else if ("Title".equalsIgnoreCase(nodeName)) { title = getValueRecursive(child); } else if ("Abstract".equalsIgnoreCase(nodeName)) { abstractt = getValueRecursive(child); } else if ("Keywords".equalsIgnoreCase(nodeName)) { addKeyWords(child); } else if ("SRS".equalsIgnoreCase(nodeName)) { defaultCrs = getValueRecursive(child); } else if ("LatLongBoundingBox".equalsIgnoreCase(nodeName)) { addLatLonBoundingBox(child); } } }
private void addLatLonBoundingBox(Node bboxNode) { NodeList childNodes = bboxNode.getChildNodes(); double x = 0, y = 0, maxx = 0, maxy = 0; for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); String nodeName = child.getNodeName(); if ("westBoundLongitude".equalsIgnoreCase(nodeName)) { x = getValueRecursiveAsDouble(child); } else if ("eastBoundLongitude".equalsIgnoreCase(nodeName)) { maxx = getValueRecursiveAsDouble(child); } else if ("southBoundLatitude".equalsIgnoreCase(nodeName)) { y = getValueRecursiveAsDouble(child); } else if ("northBoundLatitude".equalsIgnoreCase(nodeName)) { maxy = getValueRecursiveAsDouble(child); } } latlonBoundingBox = new Bbox(x, y, maxx - x, maxy - y); } }
protected void parse(Node node) { queryable = isQueryable(node); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); String nodeName = child.getNodeName(); if ("Name".equalsIgnoreCase(nodeName)) { name = getValueRecursive(child); } else if ("Title".equalsIgnoreCase(nodeName)) { title = getValueRecursive(child); } else if ("Abstract".equalsIgnoreCase(nodeName)) { abstractt = getValueRecursive(child); } else if ("KeywordList".equalsIgnoreCase(nodeName)) { addKeyWords(child); } else if ("CRS".equalsIgnoreCase(nodeName)) { crs.add(getValueRecursive(child)); } else if ("EX_GeographicBoundingBox".equalsIgnoreCase(nodeName)) { addLatLonBoundingBox(child); } else if ("BoundingBox".equalsIgnoreCase(nodeName)) { addBoundingBox(child); } else if ("MetadataURL".equalsIgnoreCase(nodeName)) { metadataUrl = new WmsLayerMetadataUrlInfo130(child); } else if ("Style".equalsIgnoreCase(nodeName)) { styleInfo.add(new WmsLayerStyleInfo130(child)); } } }
protected void parse(Node node) { queryable = isQueryable(node); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); String nodeName = child.getNodeName(); if ("Name".equalsIgnoreCase(nodeName)) { name = getValueRecursive(child); } else if ("Title".equalsIgnoreCase(nodeName)) { title = getValueRecursive(child); } else if ("Abstract".equalsIgnoreCase(nodeName)) { abstractt = getValueRecursive(child); } else if ("KeywordList".equalsIgnoreCase(nodeName)) { addKeyWords(child); } else if ("SRS".equalsIgnoreCase(nodeName)) { crs.add(getValueRecursive(child)); } else if ("BoundingBox".equalsIgnoreCase(nodeName)) { addBoundingBox(child); } else if ("LatLonBoundingBox".equalsIgnoreCase(nodeName)) { addLatLonBoundingBox(child); } else if ("MetadataURL".equalsIgnoreCase(nodeName)) { metadataUrl = new WmsLayerMetadataUrlInfo111(child); } else if ("Style".equalsIgnoreCase(nodeName)) { styleInfo.add(new WmsLayerStyleInfo111(child)); } } }
public static String getXmlNodeValue(NodeList list, String tagName, int idx) { if (list == null || list.getLength() <= idx) { return null; } Node node = list.item(idx); if (node.getNodeType() != Node.ELEMENT_NODE) { return null; } String ret = ""; NodeList textNodes = node.getChildNodes(); for (int i = 0; i < textNodes.getLength(); i++) { Node n = textNodes.item(i); if (n.getNodeType() == Node.TEXT_NODE && n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0) { ret += n.getNodeValue(); } else if (n.getNodeType() == Node.CDATA_SECTION_NODE) { ret += n.getNodeValue(); } } return ret.length() == 0 ? null : ret.replaceAll("^\\s+", "").replaceAll("\\s+$", ""); }
protected void parse(Node node) { NamedNodeMap attributes = node.getAttributes(); type = getValueRecursive(attributes.getNamedItem("type")); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); String nodeName = child.getNodeName(); if ("Format".equalsIgnoreCase(nodeName)) { format = getValueRecursive(child); } else if ("OnlineResource".equalsIgnoreCase(nodeName)) { onlineResource = createOnlineResource(child); } } }
protected void parse(Node node) { NamedNodeMap attributes = node.getAttributes(); width = getValueRecursiveAsInteger(attributes.getNamedItem("width")); height = getValueRecursiveAsInteger(attributes.getNamedItem("height")); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); String nodeName = child.getNodeName(); if ("Format".equalsIgnoreCase(nodeName)) { format = getValueRecursive(child); } else if ("OnlineResource".equalsIgnoreCase(nodeName)) { onlineResource = createOnlineResource(child); } } }