[jdom-interest] Re: need help, namespace and XML

Brett McLaughlin brett at newInstance.com
Fri Apr 20 09:01:15 PDT 2001


----- Original Message -----
From: "Trond Fleitscher" <fleitsch at stud.ntnu.no>
To: <brett.mclaughlin at javaworld.com>
Sent: Friday, April 20, 2001 8:44 AM
Subject: need help, namespace and XML


> Hi!
>
> We are four students from Norway. We are working on a project where we are
> translating xml to a java-system, and vice versa.

Hey there. Hope it's going well.

> We got this error when compiling our code:
>
> org.jdom.IllegalNameException: The name "dc:Description" is not legal for
> JDOM/XML elements: Element names cannot contain colons.
>
> Our DTD requires use of colons.( i.e <dc:Description>)
>
> we wonder if you could help us solving this problem

Hmmm... the XML 1.0 specification states that colons may be later used in
another specification, and that occurs in the XML Namespaces specification.
Because of that, JDOM assumes that if it sees a colon, it's used in a
namespace and things start to break down.

One way to work around it, and maybe even bring your docs into
namespace-awareness, is to define a namespace and associate it with the dc
prefix:

<root xmlns:dc="http://www.foo.com">

Then you could just deal with elements by their local name (Description) and
the namespace URI (http://www.foo.com)

I'm wondering, and copying the JDOM list, if there should be any way to turn
this off, as some people have your use-case.

Anyone?

-Brett

>
> with regards
>
> Trond Fleitscher
> NTNU, Trondheim, Norway
>
>
>
>




More information about the jdom-interest mailing list