sboag 01/01/29 11:46:11
Modified: java/src/org/apache/xml/utils DOMBuilder.java
Log:
Work-around for Crimson problem with setAttributeNS.
Revision Changes Path
1.7 +41 -30 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DOMBuilder.java 2001/01/08 19:15:02 1.6
+++ DOMBuilder.java 2001/01/29 19:46:04 1.7
@@ -306,42 +306,53 @@
append(elem);
- int nAtts = atts.getLength();
-
- if (0 != nAtts)
+ try
{
- for (int i = 0; i < nAtts; i++)
+ int nAtts = atts.getLength();
+
+ if (0 != nAtts)
{
-
- //System.out.println("type " + atts.getType(i) + " name " +
atts.getLocalName(i) );
- // First handle a possible ID attribute
- if (atts.getType(i).equalsIgnoreCase("ID"))
- setIDAttribute(atts.getValue(i), elem);
-
- String attrNS = atts.getURI(i);
-
- if(attrNS == null)
- attrNS = ""; // defensive, shouldn't have to do this.
-
- // 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.
- if ((attrNS.length() == 0) || atts.getQName(i).startsWith("xmlns:"))
- elem.setAttribute(atts.getQName(i), atts.getValue(i));
- else
+ for (int i = 0; i < nAtts; i++)
{
-
- // elem.setAttributeNS(atts.getURI(i), atts.getLocalName(i),
atts.getValue(i));
- elem.setAttributeNS(attrNS, atts.getQName(i), atts.getValue(i));
+
+ //System.out.println("type " + atts.getType(i) + " name " +
atts.getLocalName(i) );
+ // First handle a possible ID attribute
+ if (atts.getType(i).equalsIgnoreCase("ID"))
+ setIDAttribute(atts.getValue(i), elem);
+
+ String attrNS = atts.getURI(i);
+
+ if(attrNS == null)
+ attrNS = ""; // defensive, shouldn't have to do this.
+
+ // 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));
+ }
}
}
+
+ // append(elem);
+
+ m_elemStack.push(elem);
+
+ m_currentNode = elem;
+
+ // append(elem);
}
-
- // append(elem);
-
- m_elemStack.push(elem);
-
- m_currentNode = elem;
+ catch(java.lang.Exception de)
+ {
+ // de.printStackTrace();
+ throw new org.xml.sax.SAXException(de);
+ }
}