users@jaxb.java.net

Re: Error parsing xhtml1-strict.xsd ""Lang" is already defined."

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Sat, 16 Aug 2008 09:06:30 +0200

Hi.

> I downloaded JAXB 2.1.7 and attempted to compile the XHTML 1.0 strict Schema
> using the following command:
>
> Note: I intentionally did not use the XJC script because I wanted to control
> which JVM I was using without having to change environment variables.
>
> "C:\Program Files\Java\jdk1.5.0_15\bin\java" -jar jaxb-xjc.jar -nv
> -extension simpleMode.xsd xhtml1-strict.xsd
>
> It fails with the following error, which is repeated several times:
> [ERROR] Property "Lang" is already defined. Use <jaxb:property> to resolve
> this conflict. line 295 of file xhtml1-strict.xsd
>
> I have tried running the command using Java version 1.5 and 1.6, but both
> give the same error. I have also tried using the latest nightly builds
> (2.2), but no help there. I have read that this error used to be common, but
> was fixed in the later versions using the "-extension simpleMode.xsd"
> switch, but it still does not work for me. I have seen several usage
> examples and I don't think I'm misusing it am I?

Well, but have you tried using the <jaxb:property> to resolve the
conflict as the tool suggests?

> I'm also wondering how JAXB
> could have trouble parsing such a common schema as XHTML 1.0 Strict? Is it
> likely that there is an error in their XSD?

Not, it is not. The XSD simply declares two attributes with names
xml:lang and lang which both have the same name in Java
(getLang()/setLang(...)). You have to customize one of the attributes
to map onto "XmlLang" instead of "Lang".

I repeat, this is not a problem of schema or JAXB. This is a problem
of schema not being 100% suitable for Java representations. And it is
actually your task as a developer to introduce the customizations to
provide this compatibility.

Bye.
/lexi