The SAX handler will record the startElement
events in document order. The first will be RS
, then xsd:schema
, then xsd:complexType
, etc. You will need to keep track of each event and write the logic that works out where the table is. SAX is a low-level parser and does not by default keep the document Structure.
I would expect that you would have a indexed local data structure (perhaps a table) for the schema and that for each column you would add an entry. Then for each row as read you would look up the details in the schema (e.g. through getColumn("C1"), etc.)
For small problems you might wish to read the whole document into a DOM (I use XOM) when XPath can be used to make the referencing easy to write.