*/
@SuppressWarnings("unchecked")
protected <T extends Result>T createStAXResult(
Class<T> resultClass) throws SQLException {
StAXResult result = null;
try {
this.domResult =
new DOMResult((new SAX2DOMBuilder()).getDocument());
XMLOutputFactory factory = XMLOutputFactory.newInstance();
XMLStreamWriter xmlStreamWriter =
factory.createXMLStreamWriter(this.domResult);
if (resultClass == null || resultClass == StAXResult.class) {
result = new StAXResult(xmlStreamWriter);
} else {
Constructor ctor =
resultClass.getConstructor(XMLStreamWriter.class);
result = (StAXResult) ctor.newInstance(xmlStreamWriter);