jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r160571 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: config/ConfigurationParser.java util/DOMWalker.java
Date Fri, 08 Apr 2005 17:57:12 GMT
Author: jukka
Date: Fri Apr  8 10:57:11 2005
New Revision: 160571

URL: http://svn.apache.org/viewcvs?view=rev&rev=160571
Log:
Ah! In DOM Node.getAttribute() returns an empty string if the attribute is not given or defaulted.

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/ConfigurationParser.java?view=diff&r1=160570&r2=160571
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/ConfigurationParser.java
Fri Apr  8 10:57:11 2005
@@ -24,6 +24,7 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -431,15 +432,16 @@
             if (child.getNodeType() == Node.ELEMENT_NODE
                     && PARAM_ELEMENT.equals(child.getNodeName())) {
                 Element parameter = (Element) child;
-                String name = parameter.getAttribute(NAME_ATTRIBUTE);
+                Attr name = parameter.getAttributeNode(NAME_ATTRIBUTE);
                 if (name == null) {
                     throw new ConfigurationException("Parameter name not set");
                 }
-                String value = parameter.getAttribute(VALUE_ATTRIBUTE);
+                Attr value = parameter.getAttributeNode(VALUE_ATTRIBUTE);
                 if (value == null) {
                     throw new ConfigurationException("Parameter value not set");
                 }
-                parameters.put(name, replaceVariables(value));
+                parameters.put(
+                        name.getValue(), replaceVariables(value.getValue()));
             }
         }
 
@@ -551,9 +553,9 @@
      */
     private String getAttribute(Element element, String name)
             throws ConfigurationException {
-        String value = element.getAttribute(name);
-        if (value != null) {
-            return value;
+        Attr attribute = element.getAttributeNode(name);
+        if (attribute != null) {
+            return attribute.getValue();
         } else {
             throw new ConfigurationException(
                     "Configuration attribute " + name + " not found in "
@@ -571,9 +573,9 @@
      * @return attribute value, or the default value
      */
     private String getAttribute(Element element, String name, String def) {
-        String value = element.getAttribute(name);
-        if (value != null) {
-            return value;
+        Attr attribute = element.getAttributeNode(name);
+        if (attribute != null) {
+            return attribute.getValue();
         } else {
             return def;
         }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java?view=diff&r1=160570&r2=160571
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java Fri
Apr  8 10:57:11 2005
@@ -107,7 +107,12 @@
      * @return attribute value, or <code>null</code> if not found
      */
     public String getAttribute(String name) {
-        return current.getAttribute(name);
+        Attr attribute = current.getAttributeNode(name);
+        if (attribute != null) {
+            return attribute.getValue();
+        } else {
+            return null;
+        }
     }
 
     /**



Mime
View raw message