Bugs item #1256551, was opened at 2005-08-11 02:36 Message generated for change (Comment added) made by nobody 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 Private: No 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: Nobody/Anonymous (nobody) Date: 2007-01-10 10:23 Message: Logged In: NO I have the same problem... Any solutions? ---------------------------------------------------------------------- Comment By: Richard Eckart (wyldfire) Date: 2006-10-20 16: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 02: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 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ dom4j-dev mailing list dom4j-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-dev