Bugs item #1256551, was opened at 2005-08-11 11:36
Message generated for change (Comment added) made by wyldfire
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1256551&group_id=16035

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: set default Namespace results in wrong xml output

Initial Comment:
A short code fragment illustrate the bug:
 Document document = DocumentFactory.getInstance().
createDocument();
 Element root = document.addElement("root");
 document.setRootElement(root);
 root.addNamespace("", "http://www.test.com/yaf";);
 root.addElement("child");
 
 StringWriter strWriter = new StringWriter();
 XMLWriter writer = new XMLWriter(strWriter, new 
OutputFormat("\t", true, "ISO-8859-1"));
 writer.write(document);
 writer.flush();
 writer.close();
 System.out.println(strWriter.getBuffer().toString());

Result:
<?xml version="1.0" encoding="ISO-8859-1"?>

<root xmlns="http://www.test.com/yaf";>
        <child xmlns=""/>
</root>

Now the question (bug) is: Why conains the element 
'child' the (empty*) attribute 'xmlns'?
* Empty means no value is assigned.

----------------------------------------------------------------------

Comment By: Richard Eckart (wyldfire)
Date: 2006-10-21 01:19

Message:
Logged In: YES 
user_id=398457

I've just had trouble with namespaces as well... so here is a guess:

1) you set the default namespace
2) you add a element with the qualified name "child", no prefix, no 
namespace. The logical thing for dom4j to do here is to reset the default 
namespace for the child.

I recommend you keep a predefined set of QName instances around for all 
your tags and attributes, with properly set namespaces and prefixes.

Note that if you set a default namespace manually and then add a element 
using a QName instance that has the same namespace URI as the default 
namespace, but has a non-"" prefix set, dom4j will bind the namespace to 
this prefix.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2006-10-12 11:47

Message:
Logged In: NO 

No one answer?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1256551&group_id=16035

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to