*/
public void validate(Source source, Result result) throws SAXException,
IOException {
if (result instanceof StAXResult || result == null) {
StAXSource staxSource = (StAXSource) source;
StAXResult staxResult = (StAXResult) result;
try {
XMLStreamReader streamReader = staxSource.getXMLStreamReader();
if (streamReader != null) {
// Hand off to XMLStreamReader helper.
if (fStreamHelper == null) {
fStreamHelper = new StreamHelper();
}
fStreamHelper.validate(streamReader, staxResult);
}
else {
// Hand off to XMLEventReader helper.
if (fEventHelper == null) {
fEventHelper = new EventHelper();
}
fEventHelper.validate(staxSource.getXMLEventReader(), staxResult);
}
}
catch (XMLStreamException e) {
throw new SAXException(e);
}