stephan 2002/08/30 01:14:57
Modified: src/java/org/apache/cocoon/webapps/session/xml XMLUtil.java
Log:
NPE tested with Blackdown 1.4.1 and jakarta-tomcat-4.1.9-LE-jdk14.
The Excalibur JaxpParser take the right parser. The problem is that
XMLUtil gets different types of Element:
org.apache.xerces.dom.ElementNSImpl and
org.apache.xerces.dom.ElementImpl
And ElementImpl.getLocalName() returns null.
Revision Changes Path
1.6 +24 -8
xml-cocoon2/src/java/org/apache/cocoon/webapps/session/xml/XMLUtil.java
Index: XMLUtil.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/session/xml/XMLUtil.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLUtil.java 21 Aug 2002 06:43:58 -0000 1.5
+++ XMLUtil.java 30 Aug 2002 08:14:57 -0000 1.6
@@ -836,7 +836,7 @@
try {
getNodesFromPath(result, contextNode, path, 0);
} catch (NullPointerException npe) {
- // this NPE is thrown because the parser iss not configured
+ // this NPE is thrown because the parser is not configured
// to use DOM Level 2
throw new NullPointerException("XMLUtil.getNodeListFromPath() did catch
a NullPointerException."+
"This might be due to a missconfigured XML parser which
does not use DOM Level 2."+
@@ -861,9 +861,17 @@
l = childs.getLength();
while (m < l) {
item = childs.item(m);
- if (item.getNodeType() == Document.ELEMENT_NODE
- && item.getLocalName().equals(path[startIndex]) == true) {
- result.addNode(item);
+ if (item.getNodeType() == Document.ELEMENT_NODE) {
+ // Work around: org.apache.xerces.dom.ElementImpl doesn't
handle getLocalName() correct
+ if (item.getLocalName()!=null) {
+ if (item.getLocalName().equals(path[startIndex]) ==
true) {
+ result.addNode(item);
+ }
+ } else {
+ if (item.getNodeName().equals(path[startIndex]) ==
true) {
+ result.addNode(item);
+ }
+ }
}
m++;
}
@@ -874,9 +882,17 @@
l = childs.getLength();
while (m < l) {
item = childs.item(m);
- if (item.getNodeType() == Document.ELEMENT_NODE
- && item.getLocalName().equals(path[startIndex]) == true) {
- getNodesFromPath(result, item, path, startIndex+1);
+ if (item.getNodeType() == Document.ELEMENT_NODE) {
+ // Work around: org.apache.xerces.dom.ElementImpl doesn't
handle getLocalName() correct
+ if (item.getLocalName()!=null) {
+ if (item.getLocalName().equals(path[startIndex]) ==
true) {
+ getNodesFromPath(result, item, path, startIndex+1);
+ }
+ } else {
+ if (item.getNodeName().equals(path[startIndex]) ==
true) {
+ getNodesFromPath(result, item, path, startIndex+1);
+ }
+ }
}
m++;
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]