| 1 30 31 34 package com.nightlabs.xml; 35 36 import org.apache.xerces.util.SymbolTable; 37 import org.apache.xerces.xni.grammars.XMLGrammarPool; 38 import org.apache.xerces.xni.parser.XMLParserConfiguration; 39 import org.xml.sax.EntityResolver ; 40 import org.xml.sax.SAXException ; 41 import org.xml.sax.SAXNotRecognizedException ; 42 import org.xml.sax.SAXNotSupportedException ; 43 44 55 public class DOMParser extends org.apache.xerces.parsers.DOMParser 56 { 57 public static final boolean DEFAULT_ONLINE_MODE = false; 58 59 public DOMParser() 60 throws SAXException  61 { 62 super(); 63 setOnlineMode(DEFAULT_ONLINE_MODE); 64 } 65 public DOMParser(SymbolTable arg0) 66 throws SAXException  67 { 68 super(arg0); 69 setOnlineMode(DEFAULT_ONLINE_MODE); 70 } 71 public DOMParser(SymbolTable arg0, XMLGrammarPool arg1) 72 throws SAXException  73 { 74 super(arg0, arg1); 75 setOnlineMode(DEFAULT_ONLINE_MODE); 76 } 77 public DOMParser(XMLParserConfiguration arg0) 78 throws SAXException  79 { 80 super(arg0); 81 setOnlineMode(DEFAULT_ONLINE_MODE); 82 } 83 84 protected EntityResolver defaultEntityResolver = null; 85 protected DummyEntityResolver dummyEntityResolver = null; 86 87 103 public void setOnlineMode(boolean online) 104 throws SAXNotRecognizedException , SAXNotSupportedException  105 { 106 this.setFeature("http://xml.org/sax/features/validation", online); 111 if (!online && defaultEntityResolver == null) { 112 defaultEntityResolver = this.getEntityResolver(); 113 if (dummyEntityResolver == null) 114 dummyEntityResolver = new DummyEntityResolver(); 115 this.setEntityResolver(dummyEntityResolver); 116 } 117 else if (online && dummyEntityResolver != null) this.setEntityResolver(defaultEntityResolver); } 121 } 122 | Popular Tags |