my requirement was to creat a xml file for BOOK.
the xml file looks like below
Now my requirement changed i want to have language(which is xml:lang) as attribute for Book element.
i used some code like this
Element e= new Element("Book");
Since i have compulsion to use JDOM.
I am getting following exception
An exception occurred: org.jdom.IllegalNameException colan cannot be used.
Later i searched jdom documentation .
there was statement which goes like this
If you're trying to create the xml:lang and xml:space attributes use:
Element e =
new Element("lang", Namespace.XML_NAMESPACE);
i followed the same but did get same exception.
later i created the namespace which has xml:lang attribute
Namespace ns1 = Namespace.getNamespace("namespace","http://www.w3.org/XML/1998");
lement catalogue =new Element("Book");
But i am not able to get it right.
Any suggestion ??
Joined: Jul 22, 2011
ok i got the solution i used the following way:
Namespace nsp = Namespace.getNamespace("xml","http://www.w3.org/XML/1998/namespace");
Element catalogue =new Element("Book");