Code example for SAXParserFactory

Methods: newSAXParser, setNamespaceAware

0
	private final SAXParserFactory	saxParserFactory;
 
	public XmlConfigurator(SugarGenerator sugarConfiguration, ClassLoader classLoader) {
		this.sugarConfiguration = sugarConfiguration;
		saxParserFactory = SAXParserFactory.newInstance();
		saxParserFactory.setNamespaceAware(true);
	} 
 
	public void load(InputSource inputSource) throws ParserConfigurationException, SAXException, IOException {
		SAXParser saxParser = saxParserFactory.newSAXParser();
		saxParser.parse(inputSource, new DefaultHandler() {
			@Override 
			public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
				if (localName.equals("widget")) { //$NON-NLS-1$
					String className = attributes.getValue("class"); //$NON-NLS-1$
					try { 
						addClass(className);
					} catch (ClassNotFoundException e) {
						throw new SAXException("Cannot find Matcher class : " + className); //$NON-NLS-1$
					} 
				}