> 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
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to