[jdom-interest] Namespace declaration

Bradley S. Huffman hip at a.cs.okstate.edu
Thu Aug 8 06:19:22 PDT 2002

Sachin Keshavan writes:

> Hello all,
> I am using the following code snippet to create a Namespace for validating
> the xml file.
> Element pDetails = new
> Element("Personal_Details","xsi","http://www.w3.org/2001/XMLSchema-instance"
> );
> Attribute schemaVal = new Attribute("noNamespaceSchemaLocation",
> "C:\\SampleProgs\\PersonalDetailsSchema.xsd",pDetails.getNamespace());
> This generates the xml file in the following format
> <xsi:Personal_Details xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="C:\SampleProgs\PersonalDetailsSchema.xsd"/>
> How ever my XML editor declares this XML document as an invalid one (I use
> XMLSpy). Its says the Root Element is not defined in the DTD/Schema
> document. 
> The XML editor generates a sample XML file based on the Schema. Which is:
> <Personal_Details xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="C:\SampleProgs\PersonalDetailsSchema.xsd">
> This file is valid (XML Editor says so). The only differenece between both
> the files is the "xsi" tag which comes in the Personal_Details tag. 
> Is there any other way of setting the namespace attributes, so that XMLSpy
> identifies it as a correct file.

Element pDetails = new Element("Personal_Details");
Namespace xsi = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");


More information about the jdom-interest mailing list