1 11 package org.eclipse.pde.internal.core.text; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 16 import javax.xml.parsers.FactoryConfigurationError ; 17 import javax.xml.parsers.ParserConfigurationException ; 18 19 import org.eclipse.jface.text.IDocument; 20 import org.eclipse.pde.core.IModel; 21 import org.eclipse.pde.internal.core.util.SAXParserWrapper; 22 import org.xml.sax.SAXException ; 23 import org.xml.sax.helpers.DefaultHandler ; 24 25 public abstract class XMLEditingModel extends AbstractEditingModel { 26 27 public XMLEditingModel(IDocument document, boolean isReconciling) { 28 super(document, isReconciling); 29 } 30 31 34 public void load(InputStream source, boolean outOfSync) { 35 try { 36 fLoaded = true; 37 SAXParserWrapper parser = new SAXParserWrapper(); 38 parser.parse(source, createDocumentHandler(this, true)); 39 } catch (SAXException e) { 40 fLoaded = false; 41 } catch (IOException e) { 42 } catch (ParserConfigurationException e) { 43 } catch (FactoryConfigurationError e) { 44 } 45 } 46 47 protected abstract DefaultHandler createDocumentHandler(IModel model, boolean reconciling); 48 49 public void adjustOffsets(IDocument document) { 50 try { 51 SAXParserWrapper parser = new SAXParserWrapper(); 52 parser.parse(getInputStream(document), createDocumentHandler(this, false)); 53 } catch (SAXException e) { 54 } catch (IOException e) { 55 } catch (ParserConfigurationException e) { 56 } catch (FactoryConfigurationError e) { 57 } 58 } 59 } 60 | Popular Tags |