Turned out to be fairly easy to fix in XMLWriter.java. James, can I ask you
to apply the fix in the cvs? I'm not currently set up correctly with SSH and
cvs at my current workstation.
Proposed solution (patches to XMLWriter.java):
First allow xmlns='' to be output by changing isNamespaceDeclaration() to:
protected boolean isNamespaceDeclaration( Namespace ns ) {
if (ns != null && ns != Namespace.XML_NAMESPACE) {
String uri = ns.getURI();
if ( uri != null ) {
if ( ! namespaceStack.contains( ns ) ) {
return true;
}
}
}
return false;
}
Then add:
namespaceStack.push(Namespace.NO_NAMESPACE);
to all constructors of XMLWriter. This will make explicit the fact that
NO_NAMESPACE is the default if no other namespace has been declared. This is
necessary because otherwise xmlns="" is added to the root element of _all_
documents with no other namespace declarations, and this seems to be the
most elegant solution.
Cheers,
-- Steen
-----Original Message-----
From: Lehmann, Steen [mailto:[EMAIL PROTECTED]]
Sent: 3. september 2002 12:13
To: 'dom4j-dev'
Cc: Mogensen, Karin
Subject: [dom4j-dev] XMLWriter bug with blank default namespace?
Hi everyone,
I have a problem with serializing a document which redeclares the default
namespace to be empty, like so:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<model>
<instance>
<nons xmlns="">
</nons>
</instance>
</model>
</head>
</html>
When serializing the document using XMLWriter, the namespace declaration on
<nons> disappears, thus effectively moving the element into the default
namespace declared on the <html> element.
I'm investigating the problem myself but am short on cycles for the moment,
so I would appreciate it if one of you would take a look.
Cheers,
-- Steen
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old cell phone?
Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev