Mercurial > dive4elements > gnv-client
comparison gnv/src/main/java/de/intevation/gnv/util/XMLUtils.java @ 585:2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
gnv/trunk@736 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 05 Mar 2010 09:33:30 +0000 |
parents | cbd397712ecf |
children | b89b31293772 |
comparison
equal
deleted
inserted
replaced
584:b31e81f35b64 | 585:2e690cb2247c |
---|---|
62 attr.setPrefix(prefix); | 62 attr.setPrefix(prefix); |
63 element.setAttributeNode(attr); | 63 element.setAttributeNode(attr); |
64 } | 64 } |
65 } // class ElementCreator | 65 } // class ElementCreator |
66 | 66 |
67 public Document newDocument() { | 67 public static Document newDocument() { |
68 try { | 68 try { |
69 return DocumentBuilderFactory.newInstance().newDocumentBuilder() | 69 return DocumentBuilderFactory.newInstance().newDocumentBuilder() |
70 .newDocument(); | 70 .newDocument(); |
71 } catch (ParserConfigurationException pce) { | 71 } catch (ParserConfigurationException pce) { |
72 logger.error(pce.getLocalizedMessage(), pce); | 72 logger.error(pce.getLocalizedMessage(), pce); |
73 } | 73 } |
74 return null; | 74 return null; |
75 } | 75 } |
76 | 76 |
77 public XPath newXPath() { | 77 public static XPath newXPath() { |
78 return newXPath(null); | 78 return newXPath(null); |
79 } | 79 } |
80 | 80 |
81 public XPath newXPath(NamespaceContext namespaceContext) { | 81 public static XPath newXPath(NamespaceContext namespaceContext) { |
82 XPathFactory factory = XPathFactory.newInstance(); | 82 XPathFactory factory = XPathFactory.newInstance(); |
83 XPath xpath = factory.newXPath(); | 83 XPath xpath = factory.newXPath(); |
84 if (namespaceContext != null) { | 84 if (namespaceContext != null) { |
85 xpath.setNamespaceContext(namespaceContext); | 85 xpath.setNamespaceContext(namespaceContext); |
86 } | 86 } |
87 return xpath; | 87 return xpath; |
88 } | 88 } |
89 | 89 |
90 public Object xpath(Object root, String query, QName returnTyp) { | 90 public static Object xpath(Object root, String query, QName returnTyp) { |
91 return xpath(root, query, returnTyp, null); | 91 return xpath(root, query, returnTyp, null); |
92 } | 92 } |
93 | 93 |
94 public final String xpathString(Object root, String query, | 94 public static final String xpathString(Object root, String query, |
95 NamespaceContext namespaceContext) { | 95 NamespaceContext namespaceContext) { |
96 return (String) xpath(root, query, XPathConstants.STRING, | 96 return (String) xpath(root, query, XPathConstants.STRING, |
97 namespaceContext); | 97 namespaceContext); |
98 } | 98 } |
99 | 99 |
114 } | 114 } |
115 | 115 |
116 return null; | 116 return null; |
117 } | 117 } |
118 | 118 |
119 public Object getXPath(Object root, String query, QName returnType) { | 119 public static Object getXPath(Object root, String query, QName returnType) { |
120 return getXPath(root,query,returnType,ArtifactNamespaceContext.INSTANCE); | 120 return getXPath(root,query,returnType,ArtifactNamespaceContext.INSTANCE); |
121 } | 121 } |
122 | 122 |
123 public Object getXPath( | 123 public static Object getXPath( |
124 Object root, String query, QName returnType, NamespaceContext context | 124 Object root, String query, QName returnType, NamespaceContext context |
125 ) { | 125 ) { |
126 return xpath(root, query, returnType, context); | 126 return xpath(root, query, returnType, context); |
127 } | 127 } |
128 | 128 |
129 public String getStringXPath(String xpath) { | 129 public static String getStringXPath(String xpath) { |
130 return getStringXPath(xpath, null); | 130 return getStringXPath(xpath, null); |
131 } | 131 } |
132 | 132 |
133 public NodeList getNodeSetXPath(Object root, String query) { | 133 public static NodeList getNodeSetXPath(Object root, String query) { |
134 return (NodeList) getXPath(root, query, XPathConstants.NODESET); | 134 return (NodeList) getXPath(root, query, XPathConstants.NODESET); |
135 } | 135 } |
136 | 136 |
137 public Node getNodeXPath(Object root, String query) { | 137 public static Node getNodeXPath(Object root, String query) { |
138 return (Node) getXPath(root, query, XPathConstants.NODE); | 138 return (Node) getXPath(root, query, XPathConstants.NODE); |
139 } | 139 } |
140 | 140 |
141 public String getStringXPath(Object root, String xpath) { | 141 public static String getStringXPath(Object root, String xpath) { |
142 return getStringXPath(root, xpath, null); | 142 return getStringXPath(root, xpath, null); |
143 } | 143 } |
144 | 144 |
145 public String getStringXPath(Object root, String query, String def) { | 145 public static String getStringXPath(Object root, String query, String def) { |
146 String s = (String) getXPath(root, query, XPathConstants.STRING); | 146 String s = (String) getXPath(root, query, XPathConstants.STRING); |
147 return s == null || s.length() == 0 ? def : s; | 147 return s == null || s.length() == 0 ? def : s; |
148 } | 148 } |
149 | 149 |
150 public static Document readDocument(InputStream inputStream) { | 150 public static Document readDocument(InputStream inputStream) { |
163 logger.error(e, e); | 163 logger.error(e, e); |
164 } | 164 } |
165 return returnValue; | 165 return returnValue; |
166 } | 166 } |
167 | 167 |
168 public String writeNode2String(Node node) { | 168 public static String writeNode2String(Node node) { |
169 try { | 169 try { |
170 DOMSource source = new DOMSource(node); | 170 DOMSource source = new DOMSource(node); |
171 return writeDOMSource2String(source); | 171 return writeDOMSource2String(source); |
172 } catch (TransformerConfigurationException e) { | 172 } catch (TransformerConfigurationException e) { |
173 logger.error(e, e); | 173 logger.error(e, e); |
177 logger.error(e, e); | 177 logger.error(e, e); |
178 } | 178 } |
179 return null; | 179 return null; |
180 } | 180 } |
181 | 181 |
182 public Document reInitDocument(Document document) { | 182 public static Document reInitDocument(Document document) { |
183 | 183 |
184 StringBufferInputStream inputStream = new StringBufferInputStream(this | 184 StringBufferInputStream inputStream = new StringBufferInputStream( |
185 .writeDocument2String(document)); | 185 writeDocument2String(document)); |
186 return this.readDocument(inputStream); | 186 return readDocument(inputStream); |
187 } | 187 } |
188 | 188 |
189 public String writeDocument2String(Document document) { | 189 public static String writeDocument2String(Document document) { |
190 try { | 190 try { |
191 DOMSource source = new DOMSource(document); | 191 DOMSource source = new DOMSource(document); |
192 return writeDOMSource2String(source); | 192 return writeDOMSource2String(source); |
193 } catch (TransformerConfigurationException e) { | 193 } catch (TransformerConfigurationException e) { |
194 logger.error(e, e); | 194 logger.error(e, e); |
205 * @return | 205 * @return |
206 * @throws TransformerFactoryConfigurationError | 206 * @throws TransformerFactoryConfigurationError |
207 * @throws TransformerConfigurationException | 207 * @throws TransformerConfigurationException |
208 * @throws TransformerException | 208 * @throws TransformerException |
209 */ | 209 */ |
210 private String writeDOMSource2String(DOMSource source) | 210 private static String writeDOMSource2String(DOMSource source) |
211 throws TransformerFactoryConfigurationError, | 211 throws TransformerFactoryConfigurationError, |
212 TransformerConfigurationException, | 212 TransformerConfigurationException, |
213 TransformerException { | 213 TransformerException { |
214 TransformerFactory transformerFactory = TransformerFactory | 214 TransformerFactory transformerFactory = TransformerFactory |
215 .newInstance(); | 215 .newInstance(); |