Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java @ 961:3ba4f5a88c20
Datacage template: Added a new 'if' construct similiar to XSLT
flys-artifacts/trunk@2380 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 20 Jul 2011 20:13:49 +0000 |
parents | a2b20ed3d3b4 |
children | 2de1808503be |
comparison
equal
deleted
inserted
replaced
960:92027887775a | 961:3ba4f5a88c20 |
---|---|
34 private static final Document EVAL_DOCUMENT = | 34 private static final Document EVAL_DOCUMENT = |
35 XMLUtils.newDocument(); | 35 XMLUtils.newDocument(); |
36 | 36 |
37 private static final XPathFactory XPATH_FACTORY = | 37 private static final XPathFactory XPATH_FACTORY = |
38 XPathFactory.newInstance(); | 38 XPathFactory.newInstance(); |
39 | |
40 | |
41 | 39 |
42 protected Document template; | 40 protected Document template; |
43 | 41 |
44 public class BuildHelper | 42 public class BuildHelper |
45 { | 43 { |
180 Element element = (Element)parent; | 178 Element element = (Element)parent; |
181 | 179 |
182 element.setAttribute(name, value); | 180 element.setAttribute(name, value); |
183 } | 181 } |
184 | 182 |
183 protected void ifClause(Node parent, Element current) | |
184 throws SQLException | |
185 { | |
186 String test = current.getAttribute("test"); | |
187 | |
188 if (test.length() == 0) { | |
189 log.warn("missing 'test' attribute in 'if'"); | |
190 return; | |
191 } | |
192 | |
193 Boolean result = evaluateXPath(test); | |
194 | |
195 if (result != null && result.booleanValue()) { | |
196 NodeList subs = current.getChildNodes(); | |
197 for (int i = 0, N = subs.getLength(); i < N; ++i) { | |
198 build(parent, subs.item(i)); | |
199 } | |
200 } | |
201 } | |
202 | |
185 protected void choose(Node parent, Element current) | 203 protected void choose(Node parent, Element current) |
186 throws SQLException | 204 throws SQLException |
187 { | 205 { |
188 Node branch = null; | 206 Node branch = null; |
189 | 207 |
286 context(parent, (Element)current); | 304 context(parent, (Element)current); |
287 } | 305 } |
288 else if ("choose".equals(localName)) { | 306 else if ("choose".equals(localName)) { |
289 choose(parent, (Element)current); | 307 choose(parent, (Element)current); |
290 } | 308 } |
309 else if ("if".equals(localName)) { | |
310 ifClause(parent, (Element)current); | |
311 } | |
291 else if ("attribute".equals(localName)) { | 312 else if ("attribute".equals(localName)) { |
292 attribute(parent, (Element)current); | 313 attribute(parent, (Element)current); |
293 } | 314 } |
294 else if ("element".equals(localName)) { | 315 else if ("element".equals(localName)) { |
295 element(parent, (Element)current); | 316 element(parent, (Element)current); |