I am attempting to use JAXB to unmarshall an XML files whose schema is defined by a DTD (ugh!).
The external provider of the DTD has specified one of the element attributes as xml:lang
:
<!ATTLIST langSet
id ID #IMPLIED
xml:lang CDATA #REQUIRED
>
This comes into the xjc-generated class (standard generation; no *.xjb magic) as:
@XmlAttribute(name = "xml:lang", required = true)
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected String xmlLang;
However, when unmarshalling valid XML files with JAXB, the xmlLang
attribute is always null
.
When I edited the XML file, replacing xml:lang
with lang
and changed the @XmlAttribute
to match, unmarshalling was successful (i.e. attributes were non-null
).
I did find this http://old.nabble.com/unmarshalling-ignores-element-attribute-%27xml%27-td22558466.html. But, the resolution there was to convert to XML Schema, etc. My strong preference is to go straight from an un-altered DTD (since it is externally provided and defined by an ISO standard).
Is this a JAXB bug? Am I missing something about "namespaces" in attribute names?
FWIW, java -version
= "build 1.6.0_20-b02" and xjc -version
= "xjc version "JAXB 2.1.10 in JDK 6""
xml:lang
is an XML Schema meta-attribute, so the DTD is describing something that originated from a Schema, which would suggest to me that there's a full schema out there. – Physiology