XML header encoding

Hi All,

this question may have been asked a lot of times but i'm not able to find a clear answer.

Previously i use DTD to validate XML

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE config_jre SYSTEM"myFile.dtd">

<root>

and the java snippet used when i encode the xml file

Element root =new Element("root");

Document doc=new Document(root);

DocType docType =new DocType("root");

docType.setSystemID("myFile.dtd");

doc.setDocType(docType);

For some reasons, i change the xml validation and choose XSD

(allowing range checking, ...)

the header of the xml becomes

<?xml version="1.0" encoding="UTF-8"?>

<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

the problem is that i don't know how to add this attribute to the node.

i tried as a standard attribute but the execution failed telling that

an attribute with colons is forbidden

any help would be appreciated

[1360 byte] By [x1ongmaoa] at [2007-11-26 21:55:19]
# 1
import org.jdom.Namespace;...Namespace ns = Namespace.getNamespace("xsi", " http://www.w3.org/2001/XMLSchema-instance");root.addNamespaceDeclaration(ns);
prgguya at 2007-7-10 3:51:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

You might want to mention what XML technology you are using to do that. The DOM that's part of the standard Java API doesn't allow you to create Element objects directly, so you must be using something else.

Or perhaps if I told you that wasn't really an attribute, it was a namespace declaration, it might help you find the correct constructor from your product's documentation.

DrClapa at 2007-7-10 3:51:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
You were right i was looking for namespace. Thanks a lot :)
x1ongmaoa at 2007-7-10 3:51:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...