users@jaxb.java.net

Is it possible to use JAXB having a partial schema of the documents to be processed?

From: Jorge Medina <Jorge_Medina_Ang_Collan_at_symantec.com>
Date: Fri, 21 May 2004 13:22:06 -0400

        Let me explain the problem:
        We can receive a document that contains multiple "<elements>".
        For example:
                <document attr1="value1" attr2="value3" attr3="abc">
                        <sectionAAA>
                                <something name="somevalue"
other="othervalue"/>
                                <something name="somevalue2"
other="othervalue2"/>
                        </sectionAAA>
                        <sectionBBB someattr="valueXXX">
                                <someOtherStructure/>
                        </sectionBBB>
                        <sectionCCC>
                                <someotherElementsHere/>
                        </sectionCCC>
                </document>

        Nevertheless, the application is only interested on a couple of
<elements> and for some elements, only in a few of all the possible
attributes.

        Is it possible to use JAXB without having to write the schema for
all the element declarations and/or attributes that are not of interest
for the application ?

        I found that I can write the schema using:
 
                <xsd:anyAttribute processContent="lax"/>

        after my list of "interesting" attributes, but JAXB ignores the
line and actually complains if the unmarshaller validation is turned on
and finds an attribute not included in the schema.

        Any hints ? I don't write to write a schema for the full document
since this particular application is never going to do anything with the
the rest of the document.
 
-Jorge