[jdom-interest] Strange namespace problem
Marcel Stör
marcel at frightanic.com
Mon Nov 24 13:22:51 PST 2003
Elliotte Rusty Harold <mailto:elharo at metalab.unc.edu> wrote:
> 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.
Oh thanks, that is good to know. Why are those methods part of the API
if they are not supposed to be employed?
Regards,
Marcel
More information about the jdom-interest
mailing list