Skip to Content.
Sympa Menu

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

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Jean Pierre Malrieu <jp.malrieu AT free.fr>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Why is XOM adding xmlns="" to elements?
  • Date: Sun, 10 Jun 2007 22:51:36 +0200

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













Archive powered by MHonArc 2.6.24.

Top of Page