protected XMLReader makeReader(boolean isForWrite) { try { SAXParserFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make SAX parser factory"); } boolean useDefaultSchema = (isForWrite && defaultWriteSchema != null && factory.getSchema() == null); if (useDefaultSchema) { factory.setSchema(defaultWriteSchema); } XMLReader reader = factory.newSAXParser().getXMLReader(); if (useDefaultSchema) { factory.setSchema(null); } if (resolver != null) reader.setEntityResolver(resolver); if (errorHandler != null) reader.setErrorHandler(errorHandler); return reader; } catch (SAXException e) { logger.error("Failed to process input source with SAX content handler",e); throw new MarkLogicInternalException(e); } catch (ParserConfigurationException e) { logger.error("Failed to process input source with SAX content handler",e); throw new MarkLogicInternalException(e); } }
protected XMLReader makeReader(boolean isForWrite) { try { SAXParserFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make SAX parser factory"); } boolean useDefaultSchema = (isForWrite && defaultWriteSchema != null && factory.getSchema() == null); if (useDefaultSchema) { factory.setSchema(defaultWriteSchema); } XMLReader reader = factory.newSAXParser().getXMLReader(); if (useDefaultSchema) { factory.setSchema(null); } if (resolver != null) reader.setEntityResolver(resolver); if (errorHandler != null) reader.setErrorHandler(errorHandler); return reader; } catch (SAXException e) { logger.error("Failed to process input source with SAX content handler",e); throw new MarkLogicInternalException(e); } catch (ParserConfigurationException e) { logger.error("Failed to process input source with SAX content handler",e); throw new MarkLogicInternalException(e); } }