Code example for XMLReader

Methods: setEntityResolver, setErrorHandler, setFeature

	public XMLReader createXMLReader(EntityResolver entityResolver, boolean enableValidation) throws Exception{
		SAXParser saxParser = saxParserFactory.newSAXParser();
		XMLReader xmlReader = saxParser.getXMLReader();
		xmlReader.setFeature("", enableValidation);
		//ValidationEventHandler is provided as an ErrorHandler in XMLReader 
		// and as ValidationEventHandler in JAXB Unmarshaller (see #createUnMarshaller()). 
		//If we set error handler in XMLReader only and use JAXB to unmarshal 
		//then this error handler is ignored(!). However if we use XMLReader.parse 
		//to unmarshal then it is taken into consideration. 
		//This is why it is defined in both places so that either way 
		//our custom error handler will be used 
		xmlReader.setErrorHandler((ErrorHandler) validationEventHandler);
		return xmlReader;