Hi;
That all works great. But why is it that wordDoc.addElement("fonts", "http://schemas.microsoft.com/office/word/2003/wordml"); Doesn't add <w:fonts> if that namespace has been added with that prefix? It seems to me that the only reason to do addNamespace is if you then go do addElement("w:fonts") which means the programmer has to handle all of that mapping. And if so, is there any reason no not just do addElement("w:fonts") instead as that is shorter code? Or in that case is dom4j not aware of the namespace mapping? Thanks - dave -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Edwin Dankert Sent: Monday, December 20, 2004 3:28 AM To: David Thielen Cc: dom4j-user@lists.sourceforge.net Subject: Re: [dom4j-user] namespace question > Element wordDoc = wordML.addElement("wordDocument", > "http://schemas.microsoft.com/office/word/2003/wordml"); This creates an element in the 'http://schemas.microsoft.com/office/word/2003/wordml' namespace, without a prefix. > wordDoc.addNamespace("w", > "http://schemas.microsoft.com/office/word/2003/wordml"); This adds a namespace declaration to the element with a prefix. (does not make the element part of this namespace) > Element fonts = wordDoc.addElement("fonts", > "http://schemas.microsoft.com/office/word/2003/wordml"); Again this creates an element being part of this namespace (not setting a prefix). It is debatable wether 2 namespace declarations with the same URI should be allowed to be in scope at the same time. According to the XML spec this is however allowed so I think dom4j is handling this correctly. What I would do instead is: Namespace ns = new Namespace( "w", "http://schemas.microsoft.com/office/word/2003/wordml") ; Document wordML = DocumentHelper.createDocument(); Element wordDoc = wordML.addElement( QName.get( "wordDocument", ns)); Element fonts = wordDoc.addElement( QName.get( "fonts", ns)); Regards, Edwin ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user