cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r149078 - /cocoon/trunk/src/java/org/apache/cocoon/util/jxpath/DOMFactory.java
Date Sat, 29 Jan 2005 22:26:59 GMT
Author: sylvain
Date: Sat Jan 29 14:26:58 2005
New Revision: 149078

URL: http://svn.apache.org/viewcvs?view=rev&rev=149078
Log:
Fixing namespace detection using attributes
Modified:
   cocoon/trunk/src/java/org/apache/cocoon/util/jxpath/DOMFactory.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/util/jxpath/DOMFactory.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/util/jxpath/DOMFactory.java?view=diff&rev=149078&p1=cocoon/trunk/src/java/org/apache/cocoon/util/jxpath/DOMFactory.java&r1=149077&p2=cocoon/trunk/src/java/org/apache/cocoon/util/jxpath/DOMFactory.java&r2=149078
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/util/jxpath/DOMFactory.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/util/jxpath/DOMFactory.java	Sat Jan 29 14:26:58
2005
@@ -18,6 +18,7 @@
 import org.apache.commons.jxpath.AbstractFactory;
 import org.apache.commons.jxpath.JXPathContext;
 import org.apache.commons.jxpath.Pointer;
+import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -27,7 +28,7 @@
  * that creates DOM elements.
  *
  * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
- * @version $Id: DOMFactory.java,v 1.3 2004/03/17 09:29:15 cziegeler Exp $
+ * @version $Id$
  */
 
 public class DOMFactory extends AbstractFactory {
@@ -110,10 +111,10 @@
                 return element.getNamespaceURI();
             }
             
-            String namespace = ((Element)tmp).getAttribute(nsAttr);
-            if (namespace != null) {
-                //System.out.println("Found attribute '" + nsAttr + "'='" + namespace + "'
on element " + tmp.getNodeName());
-                return namespace;
+            // Note: stupid DOM api returns "" when an attribute doesn't exist, so we use
the Attr node.
+            Attr nsAttrNode = ((Element)tmp).getAttributeNode(nsAttr);
+            if (nsAttrNode != null) {
+                return nsAttrNode.getValue();
             }
             tmp = tmp.getParentNode();
         }

Mime
View raw message