1 package com.thaiopensource.xml.sax;2 3 import javax.xml.parsers.SAXParserFactory ;4 import javax.xml.parsers.ParserConfigurationException ;5 import org.xml.sax.XMLReader ;6 import org.xml.sax.SAXException ;7 8 import com.thaiopensource.xml.sax.XMLReaderCreator;9 10 /**11 * An <code>XMLReaderCreator</code> that uses JAXP 1.1 to create <code>XMLReader</code>s.12 * An instance of this class is <em>not</em> safe for concurrent access by multiple threads.13 *14 * @see javax.xml.parsers.SAXParserFactory15 * @author <a HREF="mailto:jjc@jclark.com">James Clark</a>16 */17 public class Jaxp11XMLReaderCreator implements XMLReaderCreator {18 19 private final SAXParserFactory factory;20 21 /**22 * Default constructor.23 */24 public Jaxp11XMLReaderCreator() {25 factory = SAXParserFactory.newInstance();26 factory.setNamespaceAware(true);27 factory.setValidating(false);28 }29 30 public XMLReader createXMLReader() throws SAXException {31 try {32 return factory.newSAXParser().getXMLReader();33 }34 catch (ParserConfigurationException e) {35 throw new SAXException (e);36 }37 }38 }39