Update of /var/cvs/src/org/mmbase/util/xml
In directory james.mmbase.org:/tmp/cvs-serv4810
Modified Files:
Tag: MMBase-1_8
DocumentReader.java
Log Message:
some XML parsers give null for Element.getLocalName
See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/util/xml
Index: DocumentReader.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/util/xml/DocumentReader.java,v
retrieving revision 1.29.2.5
retrieving revision 1.29.2.6
diff -u -b -r1.29.2.5 -r1.29.2.6
--- DocumentReader.java 23 Apr 2008 13:21:52 -0000 1.29.2.5
+++ DocumentReader.java 1 Oct 2008 09:22:00 -0000 1.29.2.6
@@ -40,7 +40,7 @@
* @author Rico Jansen
* @author Pierre van Rooden
* @author Michiel Meeuwissen
- * @version $Id: DocumentReader.java,v 1.29.2.5 2008/04/23 13:21:52 michiel
Exp $
+ * @version $Id: DocumentReader.java,v 1.29.2.6 2008/10/01 09:22:00 michiel
Exp $
* @since MMBase-1.7
*/
public class DocumentReader {
@@ -205,6 +205,8 @@
}
}
}
+
+
//xmlReader.setFeature("http://apache.org/xml/features/validation/schema",
true);
dfactory.setNamespaceAware(true);
db = dfactory.newDocumentBuilder();
@@ -502,13 +504,15 @@
return null;
} else {
String root = st.nextToken();
- if (e.getLocalName().equals("error")) {
+ String localname = e.getLocalName();
+ if (localname == null) localname = e.getNodeName();
+ if (localname.equals("error")) {
// path should start with document root element
log.error("Error occurred : (" + getElementValue(e) + ")");
return null;
- } else if (!e.getLocalName().equals(root)) {
+ } else if (!localname.equals(root)) {
// path should start with document root element
- log.error("path ["+path+"] with root ("+root+") doesn't start
with root element ("+e.getLocalName()+"): incorrect xml file" +
+ log.error("path [" + path + "] with root (" + root + ")
doesn't start with root element (" + localname + "): incorrect xml file" +
"("+getSystemId()+")");
return null;
}
@@ -519,7 +523,9 @@
for(int i = 0; i < nl.getLength(); i++) {
if (! (nl.item(i) instanceof Element)) continue;
e = (Element)nl.item(i);
- if (e.getLocalName().equals(tag)) continue OUTER;
+ String ln = e.getLocalName();
+ if (ln == null) ln = e.getNodeName();
+ if (ln.equals(tag)) continue OUTER;
}
// Handle error!
return null;
@@ -587,9 +593,11 @@
NodeList nl = e.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node n = nl.item(i);
+ String localname = n.getLocalName();
+ if (localname == null) localname = n.getNodeName();
if (n.getNodeType() == Node.ELEMENT_NODE &&
(ignoretag ||
- ((Element)n).getLocalName().equalsIgnoreCase(tag))) {
+ localname.equalsIgnoreCase(tag))) {
v.add(n);
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs