You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@locus.apache.org on 2000/01/20 21:52:07 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/dom DeepNodeListImpl.java
lehors 00/01/20 12:52:07
Modified: java/src/org/apache/xerces/dom DeepNodeListImpl.java
Log:
fixed namespace support
Revision Changes Path
1.2 +42 -17 xml-xerces/java/src/org/apache/xerces/dom/DeepNodeListImpl.java
Index: DeepNodeListImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DeepNodeListImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeepNodeListImpl.java 1999/11/09 01:13:15 1.1
+++ DeepNodeListImpl.java 2000/01/20 20:52:07 1.2
@@ -136,10 +136,8 @@
/** Constructor for Namespace support. */
public DeepNodeListImpl(NodeImpl rootNode, String nsName, String tagName) {
this(rootNode, tagName);
- this.nsName = nsName;
- enableNS = ( nsName == null
- || nsName.equals("")
- || nsName.equals("*") ) ? false : true;
+ this.nsName = (nsName != null && !nsName.equals("")) ? nsName : null;
+ enableNS = true;
}
//
@@ -229,20 +227,47 @@
// ("*" matches anything.)
if (current != rootNode
&& current != null
- && current.getNodeType() == Node.ELEMENT_NODE
- && (tagName.equals("*")
- || ((ElementImpl) current).getTagName().equals(tagName))
- // DOM2: Namespace logic.
- && (!enableNS
- || ( enableNS
- && ((ElementImpl) current).getNamespaceURI() != null
- && ((ElementImpl) current).getNamespaceURI().equals(nsName)
- )
- )
- )
- {
- return current;
+ && current.getNodeType() == Node.ELEMENT_NODE) {
+ if (!enableNS) {
+ if (tagName.equals("*") ||
+ ((ElementImpl) current).getTagName().equals(tagName))
+ {
+ return current;
+ }
+ } else {
+ // DOM2: Namespace logic.
+ if (tagName.equals("*")) {
+ if (nsName != null && nsName.equals("*")) {
+ return current;
+ } else {
+ ElementImpl el = (ElementImpl) current;
+ if ((nsName == null
+ && el.getNamespaceURI() == null)
+ || (nsName != null
+ && nsName.equals(el.getNamespaceURI())))
+ {
+ return current;
+ }
+ }
+ } else {
+ ElementImpl el = (ElementImpl) current;
+ if (el.getLocalName() != null
+ && el.getLocalName().equals(tagName)) {
+ if (nsName != null && nsName.equals("*")) {
+ return current;
+ } else {
+ if ((nsName == null
+ && el.getNamespaceURI() == null)
+ || (nsName != null &&
+ nsName.equals(el.getNamespaceURI())))
+ {
+ return current;
+ }
+ }
+ }
+ }
}
+ }
// Otherwise continue walking the tree
}