users@jaxb.java.net

Partial unmarshalling & xs:anyType

From: <jurgis_at_viesite.edu.lv>
Date: Mon, 6 Jun 2011 09:29:12 +0000 (GMT)

Hi,
to get better understanding what I'm trying to do I'll explain it as
shortly as I can :)
So I have XML message protocol like SOAP, each XML message contains
"envelope" and "payload".
For now I'm doing envelope parsing using SAX (because message type is
used for unmarshalling), payload part is processed by jaxb followed by
partial unmarshalling sample.
There are bunch of message types which may contain static and dynamic
tags in payload. For each message type I created .xsd.
Example for reply:
<reply>
<type>action1</type>
<lasted>0.01</lasted>
<content>
<static>val</static>
<static1>val</static1>
<dynamic>....</dynamic>
</content>
</reply>
For such message I created .xsd and defined dynamic tag as xs:anyType
that's worked pretty well.

Problem is for messages like that:
<reply>
<type>action2</type>
<lasted>0.01</lasted>
<content>
<dynamic_data>....</dynamic_data>
</content>
</reply>
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.
(Each schema is generated by separate xjc ant task into different
package to overcome tag/class duplicate problem because of content tag
which is same for all types of messages and defines payload of
message).

Any ideas what am I doing wrong?

Thanks in advance