Skip to Content.
Sympa Menu

xom-interest - Re: [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: "Michael Kay" <mike AT saxonica.com>
  • To: "'Jean Pierre Malrieu'" <jp.malrieu AT free.fr>, <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Why is XOM adding xmlns="" to elements?
  • Date: Sun, 10 Jun 2007 22:20:04 +0100

If you want the element responseDeclaration to be in the namespace
http://www.imsglobal.org/xsd/imsqti_v2p1, then you must put it in that
namespace. It won't go in that namespace simply because that's the namespace
of its parent. The xmlns="" is being added because responseDeclaration, the
way you created it, is in no namespace.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: xom-interest-bounces AT lists.ibiblio.org
> [mailto:xom-interest-bounces AT lists.ibiblio.org] On Behalf Of
> Jean Pierre Malrieu
> Sent: 10 June 2007 21:52
> To: xom-interest AT lists.ibiblio.org
> Subject: [XOM-interest] Why is XOM adding xmlns="" to elements?
>
> 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
>
>
>
>
>
>
>
>
>
> _______________________________________________
> XOM-interest mailing list
> XOM-interest AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/xom-interest





Archive powered by MHonArc 2.6.24.

Top of Page