01: package org.kohsuke.rngom.parse.xml;
02:
03: import org.xml.sax.DTDHandler;
04: import org.xml.sax.SAXException;
05: import org.relaxng.datatype.ValidationContext;
06:
07: import java.util.Hashtable;
08:
09: public abstract class DtdContext implements DTDHandler,
10: ValidationContext {
11: private final Hashtable notationTable;
12: private final Hashtable unparsedEntityTable;
13:
14: public DtdContext() {
15: notationTable = new Hashtable();
16: unparsedEntityTable = new Hashtable();
17: }
18:
19: public DtdContext(DtdContext dc) {
20: notationTable = dc.notationTable;
21: unparsedEntityTable = dc.unparsedEntityTable;
22: }
23:
24: public void notationDecl(String name, String publicId,
25: String systemId) throws SAXException {
26: notationTable.put(name, name);
27: }
28:
29: public void unparsedEntityDecl(String name, String publicId,
30: String systemId, String notationName) throws SAXException {
31: unparsedEntityTable.put(name, name);
32: }
33:
34: public boolean isNotation(String notationName) {
35: return notationTable.get(notationName) != null;
36: }
37:
38: public boolean isUnparsedEntity(String entityName) {
39: return unparsedEntityTable.get(entityName) != null;
40: }
41:
42: public void clearDtdContext() {
43: notationTable.clear();
44: unparsedEntityTable.clear();
45: }
46: }
|