Skip to main content

About xs:any

3 replies [Last post]
wangzaixiang
Offline
Joined: 2004-11-24
Points: 0

I am not clear how the JAXB2 support the xs:any schema element. Could anybody provide a example snippet?

also, should the JAXB2 support reverse mapping a xml schema to a java package without register it firstly? like some ResoureResolver interface, when a schema mapping is not found, call the resolver to revert mapping to a java package.

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
Points: 0

It's not set in stone but in the upcoming early access of the JAXB RI, it's going to be mapped to:

1. org.w3c.dom.Element if processContents="skip"
2. Object if processContents="strict", and at the runtime you get instances of JAXB-bound classes that match the element names
3. Object if processContents="lax", and at the runtime you get a mixture of DOM and instances of JAXB-bound classes if the element name matches.

Personally, I think it's better if all three cases always map to DOM Element, as the signature clearly shows what you would expect. But this is how it is done in the next drop.

Does this work for you?

wangzaixiang
Offline
Joined: 2004-11-24
Points: 0

>3. Object if processContents="lax", and at the runtime you get a mixture of DOM and instances of JAXB-bound classes if the element name matches.

How to mixture DOM and POJO at the same time?

>2. Object if processContents="strict", and at the runtime you get instances of JAXB-bound classes that match the element names

That is most the case i wanted, so, given element, how to find the POJO class for the element? it maynot add to the JAXBContext already?

kohsuke
Offline
Joined: 2003-06-09
Points: 0

> How to mixture DOM and POJO at the same time?

For example if you have a class named 'Foo' bound to QName(uri="",local="foo"), if the instance contains this foo element, you get an instance of Foo. Otherwise you get a DOM element representing whatever element it was.

Since the signature is 'Object', it can hold both.

Personally I don't like this --- I'd rather get DOM elements all the times. I think it's easier to work with.

> That is most the case i wanted, so, given
> element, how to
> find the POJO class for the element? it maynot
> add to the JAXBContext already?

You have to specify those classes when creating JAXBContext.