Skip to main content

schema generation with xs:language

2 replies [Last post]
kkohlstedt
Offline
Joined: 2005-11-15

We are using com.sun.tools.jxc.SchemaGenTask to generate schema from our java files. I'm trying to figure out if its possible to generate XML elements with the type of xs:language rather than xs:string. For example, I've got a member variable defined as follows.

@XmlJavaTypeAdapter(LocaleAdapter.class)
@XmlElement(name = "Locale")
protected java.util.Locale locale;

In the above example LocaleAdapter.class is just a custom adapter that I've defined which maps java.util.Locale to a String. What I would like to have happen though is for the element to be generated as

rather than

Any suggestions? Is what I'm thinking possible?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09

Try

[code]
@XmlJavaTypeAdapter(LocaleAdapter.class)
@XmlSchemaType(type="language")
@XmlElement(name = "Locale")
protected java.util.Locale locale;
[/code]

Note that this was only implemented recently, so if you are using EA2, this wouldn't work. Try the nightly builds for this.

kkohlstedt
Offline
Joined: 2005-11-15

Great, thanks. I was able to get it working with the following.

[code]
@XmlJavaTypeAdapter(LocaleAdapter.class)
@XmlSchemaType(name="language")
@XmlElement(name = "Locale")
protected java.util.Locale locale;
[/code]