users@jaxb.java.net

Re: Partial unmarshalling & xs:anyType

From: Jurgis <jurgis_at_viesite.edu.lv>
Date: Mon, 06 Jun 2011 15:44:04 +0300

You are right indeed Content should map to java.lang.Object and I expect
it so. So it means I can't get this content through generated classes,
can I? What would be the best way to handle such cases then? Do I need
to make exceptions for such cases or are there any approach (maybe
workaround) to do that not breaking current code flow which as I told
before uses SAX and calls unmarshaller when content tag is found?

On 2011.06.06. 14:17, Wolfgang Laun wrote:
> On 6 June 2011 11:29, <jurgis_at_viesite.edu.lv
> <mailto:jurgis_at_viesite.edu.lv>> wrote:
>
>
>
> <content>
> <dynamic_data>....</dynamic_data>
> </content>
>
> tag name dynamic_data is not known so my purpose is to define content
> tag as anyType so I can get it as Element and then dive into
> "manually".
> So I defined schema like that:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
> <xs:element name="content" type="xs:anyType"/>
> </xs:schema>
>
> Unfortunately xjc generated only ObjectFactory.java file not Content
> class.
>
>
> What would you expect to be in the generated "Content" class? If you
> don't know anything, the type of the element <content> is
> java.lang.Object, and you don't need Java code for that.
>
> See
> http://jaxb.java.net/tutorial/section_2_2_16_1-Elements-With-Any-Type.html#Elements%20With%20Any%20Type
>
> -W
>