private XMLReader createDTDParser(SAXTarget out) throws SAXException {
		XMLReader parser = null;

		// Get a parser instance
		try {
			parser = createParser();
		} catch (Exception ex1) {
			throw new SAXException("Error in SAX parser allocation", ex1);
		}

		// Register handlers
		if (out.getDTDHandler() != null) {
			parser.setDTDHandler(out.getDTDHandler());
		}
		if (out.getEntityResolver() != null) {
			parser.setEntityResolver(out.getEntityResolver());
		}
		if (out.getLexicalHandler() != null) {
			try {
				parser.setProperty(SAX_PROPERTY_LEXICAL_HANDLER,
						out.getLexicalHandler());
			} catch (SAXException ex1) {
				try {
					parser.setProperty(SAX_PROPERTY_LEXICAL_HANDLER_ALT,
							out.getLexicalHandler());
				} catch (SAXException ex2) {
					// Forget it!
				}
			}
		}
		if (out.getDeclHandler() != null) {
			try {
				parser.setProperty(SAX_PROPERTY_DECLARATION_HANDLER,
						out.getDeclHandler());
			} catch (SAXException ex1) {
				try {
					parser.setProperty(SAX_PROPERTY_DECLARATION_HANDLER_ALT,
							out.getDeclHandler());
				} catch (SAXException ex2) {
					// Forget it!
				}
			}
		}

		// Absorb errors as much as possible, per Laurent
		parser.setErrorHandler(new DefaultHandler());

		return parser;
	}