[jdom-interest] JDOM parsing problem

Ching-Kuan Thum ckthum at newstakes.com
Fri Jul 21 22:28:07 PDT 2000


hi,

    I'm using JDOM beta 4 to parse the following test file :

<?xml version="1.0" encoding="UTF-8"?>
<test.a>abc</test.a>

and get the following error :

G:\jdom>java -classpath lib/xerces.jar;build/jdom-b4.jar;. Test
org.jdom.JDOMException: The name "test.a" is not legal for JDOM/XML
elements: .
is not allowed in XML names..: The name "test.a" is not legal for JDOM/XML
eleme
nts: . is not allowed in XML names..
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:231)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:286)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:267)
        at Test.main(Test.java:14)
Root cause: org.jdom.IllegalNameException: The name "test.a" is not legal
for JD
OM/XML elements: . is not allowed in XML names..
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1225)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:220)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:286)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:267)
        at Test.main(Test.java:14)

I've parsed the file with both DOM and SAX parser come with xerces and have
no problem.

If I read the xml spec correctly, "." can be accepted as the name of an xml
element.
I would like to know if this is jdom specific requirement as the DTD that
I'm using for production has plenty of such element name.  If this is jdom
specific, I don't think I can use it for production though I like the idea
and the handy API very much :) (after struggling with the DOM api for long
time).

Thanks for any help.

Regards,
Ching-Kuan Thum

Extract from XML spec:
------------------------
Names and Tokens
[4]  NameChar ::=  Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar |
Extender
[5]  Name ::=  (Letter | '_' | ':') (NameChar)*
[6]  Names ::=  Name (S Name)*
[7]  Nmtoken ::=  (NameChar)+
[8]  Nmtokens ::=  Nmtoken (S Nmtoken)*






More information about the jdom-interest mailing list