changeset 5585:4b281c7046c8

Used DOM instead of XPath to extract main values.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Apr 2013 23:27:48 +0200
parents d35a0bc153fa
children 966237892c9b
files flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java
diffstat 1 files changed, 7 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java	Fri Apr 05 23:19:01 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java	Fri Apr 05 23:27:48 2013 +0200
@@ -131,7 +131,7 @@
             new ArrayList<WQInfoObject>(num);
 
         for (int i = 0; i < num; i++) {
-            WQInfoObject obj = buildWQInfoObject(list.item(i));
+            WQInfoObject obj = buildWQInfoObject((Element)list.item(i));
 
             if (obj != null) {
                 objects.add(obj);
@@ -176,20 +176,15 @@
      *
      * @return a valid WQInfoObject.
      */
-    protected WQInfoObject buildWQInfoObject(Node node) {
-
-        // TODO: Replace this expensive XPaths with simpler use of DOM.
-        String name = XMLUtils.xpathString(
-            node, "@name", ArtifactNamespaceContext.INSTANCE);
+    protected static WQInfoObject buildWQInfoObject(Element node) {
 
-        String type = XMLUtils.xpathString(
-            node, "@type", ArtifactNamespaceContext.INSTANCE);
+        String uri = ArtifactNamespaceContext.NAMESPACE_URI;
 
-        String value = XMLUtils.xpathString(
-            node, "@value", ArtifactNamespaceContext.INSTANCE);
+        String name  = node.getAttributeNS(uri, "name");
+        String type  = node.getAttributeNS(uri, "type");
+        String value = node.getAttributeNS(uri, "value");
 
-
-        if (name != null && type != null) {
+        if (!name.isEmpty() && !type.isEmpty()) {
             try {
                 return new WQInfoObjectImpl(
                     name,

http://dive4elements.wald.intevation.org