jkesselm 2002/07/10 14:44:21
Modified: java/src/org/apache/xml/utils DOMBuilder.java
Log:
<Blush>
This was still trying to switch between setAttribute() and
setAttributeNS(). Correct usage of DOM Level 2 would be to
always use setAttributeNS(), and simply set a null URI when the
node is not namespaced. (Basically, the L1 versions of
createElement, createAttribute, setAttribute and setAttributeNode
should be considered deprecated with the sole exception of
manipulating a DOM intended to be viewed *only* as Level 1.)
I could swear we fixed this a VERY long time ago...
Good catch, thanks for calling it to our attention.
</Blush>
Revision Changes Path
1.11 +5 -11 xml-xalan/java/src/org/apache/xml/utils/DOMBuilder.java
Index: DOMBuilder.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/DOMBuilder.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DOMBuilder.java 3 Jan 2002 20:12:19 -0000 1.10
+++ DOMBuilder.java 10 Jul 2002 21:44:21 -0000 1.11
@@ -325,21 +325,15 @@
String attrNS = atts.getURI(i);
- if(attrNS == null)
- attrNS = ""; // defensive, shouldn't have to do this.
+ if("".equals(attrNS))
+ attrNS = null; // DOM represents no-namespace as null
// System.out.println("attrNS: "+attrNS+", localName:
"+atts.getQName(i)
// +", qname: "+atts.getQName(i)+", value:
"+atts.getValue(i));
// Crimson won't let us set an xmlns: attribute on the DOM.
String attrQName = atts.getQName(i);
- if ((attrNS.length() == 0) /* || attrQName.startsWith("xmlns:") ||
attrQName.equals("xmlns") */)
- elem.setAttribute(attrQName, atts.getValue(i));
- else
- {
-
- // elem.setAttributeNS(atts.getURI(i), atts.getLocalName(i),
atts.getValue(i));
- elem.setAttributeNS(attrNS, attrQName, atts.getValue(i));
- }
+ // ALWAYS use the DOM Level 2 call!
+ elem.setAttributeNS(attrNS,attrQName, atts.getValue(i));
}
}
@@ -715,7 +709,7 @@
qname = "xmlns:"+prefix;
Element elem = (Element)m_currentNode;
- String val = elem.getAttribute(qname);
+ String val = elem.getAttribute(qname); // Obsolete, should be DOM2...?
if(val == null)
{
elem.setAttributeNS("http://www.w3.org/XML/1998/namespace",
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]