1 package com.thaiopensource.xml.sax; 2 3 import org.xml.sax.SAXException ; 4 import org.xml.sax.XMLReader ; 5 import org.xml.sax.SAXNotRecognizedException ; 6 import org.xml.sax.SAXNotSupportedException ; 7 import org.xml.sax.helpers.XMLReaderFactory ; 8 9 import com.thaiopensource.xml.sax.XMLReaderCreator; 10 11 18 public class Sax2XMLReaderCreator implements XMLReaderCreator { 19 private final String className; 20 21 24 public Sax2XMLReaderCreator() { 25 this.className = null; 26 } 27 28 36 public Sax2XMLReaderCreator(String className) { 37 this.className = className; 38 } 39 40 public XMLReader createXMLReader() throws SAXException { 41 XMLReader xr; 42 if (className == null) 43 xr = XMLReaderFactory.createXMLReader(); 44 else 45 xr = XMLReaderFactory.createXMLReader(className); 46 xr.setFeature("http://xml.org/sax/features/namespaces", true); 47 xr.setFeature("http://xml.org/sax/features/namespace-prefixes", false); 48 try { 49 xr.setFeature("http://xml.org/sax/features/validation", false); 50 } 51 catch (SAXNotRecognizedException e) { 52 } 53 catch (SAXNotSupportedException e) { 54 } 55 return xr; 56 } 57 } 58 | Popular Tags |