} catch (URISyntaxException ex) {
throw new SAXException(ex);
}
if (document == null) {
DOMResult domResult = new DOMResult();
try {
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
SAXTransformerFactory saxTransformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
TransformerHandler transformerHandler = saxTransformerFactory.newTransformerHandler();
transformerHandler.setResult(domResult);
xmlReader.setContentHandler(new XIncludeHandler(transformerHandler, uriDocMap));
xmlReader.parse(url.toExternalForm());
} catch (TransformerConfigurationException e) {
throw new SAXException(e);
} catch (IOException e) {
throw new SAXException(e);
}
document = (Document) domResult.getNode();
document.setDocumentURI(url.toExternalForm());
try {
uriDocMap.put(url.toURI(), document);
} catch (URISyntaxException e) {
throw new SAXException(e);