Hi
While testing my stuff I stumbled across a bug in SetContentHandler. It
does not work properly with default namespaces (<myelem xmlns="http:/www...).
Could someone please patch that class by replacing the startElement
method with the one below? I also added a check to avoid duplicate
namespace declarations. Thanks.
public void startElement(String uri, String localName,
String qName, Attributes attributes)
throws SAXException {
newContent.append("<");
newContent.append(qName);
for (int i = 0; i < attributes.getLength(); i++) {
String qn = attributes.getQName(i);
newContent.append(" ");
newContent.append(qn);
newContent.append("=");
newContent.append("\"");
newContent.append(attributes.getValue(i));
newContent.append("\"");
//Avoid duplicate namespace declarations
if (qn.startsWith("xmlns")) {
String ln = attributes.getLocalName(i);
if (ln.equals("xmlns")) {
namespaces.remove("");
} else {
namespaces.remove(ln);
}
}
}
Enumeration enum = namespaces.keys();
while ( enum.hasMoreElements() ) {
String key = (String) enum.nextElement();
newContent.append(" xmlns");
if (key.length() > 0) {
newContent.append(":");
newContent.append(key);
}
newContent.append("=");
newContent.append("\"");
newContent.append(namespaces.get(key));
newContent.append("\"");
namespaces.remove(key);
}
newContent.append(">");
}
Jeremias M�rki
mailto:[EMAIL PROTECTED]
OUTLINE AG
Postfach 3954 - Rhynauerstr. 15 - CH-6002 Luzern
Fon +41 (41) 317 2020 - Fax +41 (41) 317 2029
Internet http://www.outline.ch
----------------------------------------------------------------------
Post a message: mailto:[EMAIL PROTECTED]
Unsubscribe: mailto:[EMAIL PROTECTED]
Contact adminstrator: mailto:[EMAIL PROTECTED]
Read archived messages: http://archive.xmldb.org/
----------------------------------------------------------------------