[jdom-interest] Strange namespace problem

Elliotte Rusty Harold elharo at metalab.unc.edu
Mon Nov 24 06:37:38 PST 2003


At 3:05 PM +0100 11/24/03, Marcel Stor wrote:
>Hi all,
>
>I need to produce the following XML tag:
><IT-P_CDB xmlns="http://www.it-p.ch/namespace"
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xsi:schemaLocation="http://www.it-p.ch/namespace
>http://www.praut.com/CDB.xsd" type="XML">
>
>I do this through:
>Namespace schemaNS = Namespace.getNamespace("xsi",
>"http://www.w3.org/2001/XMLSchema-instance");
>Namespace defaultNS =
>Namespace.getNamespace("http://www.it-p.ch/namespace");
>Element root = new Element("IT-P_CDB");
>root.setNamespace(defaultNS);
>root.addNamespaceDeclaration(schemaNS);

Don't call setNamespace or addNamespaceDeclaration. The namespaces 
should be passed as arguments to the Element and Attribute 
constructors.
-- 

   Elliotte Rusty Harold
   elharo at metalab.unc.edu
   Effective XML (Addison-Wesley, 2003)
   http://www.cafeconleche.org/books/effectivexml
   http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA



More information about the jdom-interest mailing list