1 11 package org.eclipse.pde.internal.builders; 12 13 import java.io.*; 14 15 import javax.xml.parsers.*; 16 17 import org.eclipse.core.resources.*; 18 import org.eclipse.core.runtime.*; 19 import org.xml.sax.*; 20 21 public class ValidatingSAXParser { 22 23 private static SAXParserFactory fFactory; 24 25 public static void parse(IFile file, XMLErrorReporter reporter) { 26 InputStream stream = null; 27 try { 28 stream = file.getContents(); 29 getParser().parse(stream, reporter); 30 } catch (CoreException e) { 31 } catch (SAXException e) { 32 } catch (IOException e) { 33 } catch (ParserConfigurationException e) { 34 } finally { 35 try { 36 if (stream != null) 37 stream.close(); 38 } catch (IOException e1) { 39 } 40 } 41 } 42 43 private static SAXParser getParser() 44 throws ParserConfigurationException, SAXException { 45 if (fFactory == null) { 46 fFactory = SAXParserFactory.newInstance(); 47 } 48 return fFactory.newSAXParser(); 49 } 50 51 } 52 | Popular Tags |