users@jaxb.java.net

Attributes in xml: namespace

From: Jacob Zwiers <Jacob.Zwiers_at_tpsgc-pwgsc.gc.ca>
Date: Fri, 11 Jun 2010 09:48:37 -0400

A couple of days ago, I created a question on Stack Overflow re/ element attributes within the xml: namespace (see http://stackoverflow.com/questions/3006373/jaxb-unable-to-handle-attribute-with-colon-in-name for details).

With a bit more digging, I answered the question myself by modifying the @XmlAttribute annotation (generated from xjc) from:

   @XmlAttribute(name = "xml:lang", required = true)

to:

   @XmlAttribute(name = "lang", namespace="http://www.w3.org/XML/1998/namespace", required = true)

However, it left me with an outstanding question: is this a bug in xjc (where it should treat xml: the same way that XMLStreamReader does), a bug in the unmarshalling process (where it should do the same) or am I missing a mapping somewhere that would instruct xjc to include the namespace in the @XmlAttribute declaration?

I recognize I'm using DTDs and admit that I'm very reluctant to do any sort of automated conversion to XSD. If this small post-generation edit is the price, so be it ... But I just want to make sure I'm not missing anything.

Thanks...
jz