Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] Adding attributes which contain colons to root
 element

Black, Henry

2005-07-22

Replies:

I am using XML and JDOM for the first time, and want to build a document using:

 

      Element root = new Element("myReport");

      Document doc = new Document(root);

 

Then I want to add attributes for namespace and schema

 

      root.setAttribute("xmlns:asi",

                        http://www.broken.com/asi)

      root.setAttribute("xsi:schemaLocation",

                         "C:/config/myReport.xsd");

 

This results in an error which states:  "Attribute names cannot contain colons."

 

I think I can deal with the namespace by assigning the namespace when I build each element.  I have not figured out how to assign a schema location without using the SAXBuilder class to build my document.  That option seems to require that I have a physical xml file, which I don't need.

 

Suggestions?

 

Thanks.

 

     - Henry

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.