[XOM-interest] Why is XOM adding xmlns="" to elements?

Jean Pierre Malrieu jp.malrieu at free.fr
Sun Jun 10 16:51:36 EDT 2007


Hi,

As you will discover very soon, I know very little about XML and XML  
schemas...
I want to use XOM to generate xml documents, because XOM seems to be  
easier to understand than other APIs.

My documents must look like this:

<?xml version="1.0" encoding="UTF-8"?>
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1  
imsqti_v2p1.xsd"
	title = "title">
     <responseDeclaration>
         blabla
     </responseDeclaration>
</assessmentItem>

Therefore I have tried to write the following java code:

Element root = new Element("assessmentItem");
root.setNamespaceURI("http://www.imsglobal.org/xsd/imsqti_v2p1");
root.addNamespaceDeclaration("xsi","http://www.w3.org/2001/XMLSchema- 
instance");
root.addAttribute(new Attribute("xsi:schemaLocation", "http:// 
www.w3.org/2001/XMLSchema-instance", "http://www.imsglobal.org/xsd/ 
imsqti_v2p1 imsqti_v2p1.xsd"));
root.addAttribute(new Attribute("title,"title"));
Element rp = new Element("responseDeclaration");

but this leads to an output like:

<?xml version="1.0" encoding="UTF-8"?>
<assessmentItem
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	title = "title"
     xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1  
imsqti_v2p1.xsd"
	xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1">
     <responseDeclaration xlmns="">
         blabla
     </responseDeclaration>
</assessmentItem>

which is not valid.
How do I get rid of the xmlns="" in the responseDeclaration element?

Thanks.

JPM











More information about the XOM-interest mailing list