EXT-Pennington, Dale K wrote:
For background info, I am an experienced C/C++ developer, but rather new
to XML.
I have downloaded Xerces, build the samples, and have the basics down.
The issue I am looking at is as follows :
...
Now the method I envision would work as follows :
1) Do a non-validating pass with no schema specified.
2) Get the root element from the first pass, use it to determine the
actual message type and reparse/validate with the appropriate schema
specified.
Is this my best method, or is there a way to tell the parser (I intend
to use the DOMBuilder class) that there are multiple possible schemas
that the XML might parse to (differentiated by root element).
If the different message types use unique XML namespaces, then you can use
the external schema location property:
http://xerces.apache.org/xerces-c/program-dom.html#DOMBuilderProperties
If the message don't use unique namespaces, then you will need to look at
the root element. Note that you can use the SAX2 parser, and stop parsing
after you see the root element.
Dave