Re: FW: JDOM XML Schema issue

Hi Badal,

[Removed cross-post to www-xml-schema-comments@w3.org since that
mailing list is for comments on the XML Schema standard, and this
isn't a comment on the XML Schema standard. Actually, this message
hasn't really got anything to do with XML Schema at all...]

> The line in red is not the one I want in the xml. How can I get it
> to say xsi:noNamespaceSchemaLocation="ProductImage.xsd" reather then
> xmlns:noNamespaceSchemaLocation="C:/badal/amazon/ProductImage.xsd.

The code you're using to create this is:

  root.addNamespaceDeclaration(Namespace.getNamespace
    ("noNamespaceSchemaLocation","C:/badal/amazon/ProductImage.xsd"));

Since you're saying "add a namespace declaration", the code is
adding a namespace declaration (an xmlns:prefix="URI" attribute).

If you want to add an attribute called xsi:noNamespaceSchemaLocation,
where 'xsi' is associated with the namespace
'http://www.w3.org/2001/XMLSchema-instance' then you need to use the
.setAttribute() method:

  root.setAttribute("noNamespaceSchemaLocation",
                    "C:/badal/amazon/ProductImage.xsd",
                    Namespace.getNamespace("xsi",
                      "http://www.w3.org/2001/XMLSchema-instance"))

The first argument is the name of the attribute; the second argument
is its value; the third argument is the namespace that it belongs to.
                      
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Thursday, 17 July 2003 12:40:58 UTC