users@jaxb.java.net

Mapping of SAX events to corresponding JAXB classes

From: Claus Nagel <claus.nagel_at_gmail.com>
Date: Fri, 28 Sep 2007 16:59:05 +0200

Hello everyone -

I have generated JAXB classes from a given XSD schema. Since I have to deal
with potentially very large XML instance documents, I am using a SAX parser
to read those documents. I have successfully implemented a partial
unmarshalling according to the sample provided by the JAXB RI 2.1 package.
That's working fine so far.

For an XML start element the SAX parser calls the following method (well,
this is nothing new to you, of course):

public void startElement(String uri, String localName, String qName,
Attributes atts) throws SAXException {
    // things to do
}

Now my question: Is it possible - just based on these values provided by the
SAX parser - to get to know which JAXB class would be instantiated? So, is
there a way to say: "Ok, this start element would be mapped to this JAXB
class", without actually unmarshalling the whole XML chunk?

Thanks for your answers,
Claus