| 1 |
package com.thaiopensource.relaxng.parse.sax; |
| 2 |
|
| 3 |
import org.relaxng.datatype.ValidationContext; |
| 4 |
import org.xml.sax.DTDHandler; |
| 5 |
import org.xml.sax.SAXException; |
| 6 |
|
| 7 |
import java.util.HashSet; |
| 8 |
import java.util.Set; |
| 9 |
|
| 10 |
public abstract class DtdContext implements DTDHandler, ValidationContext { |
| 11 |
private final Set<String> notations; |
| 12 |
private final Set<String> unparsedEntities; |
| 13 |
|
| 14 |
public DtdContext() { |
| 15 |
notations = new HashSet<String>(); |
| 16 |
unparsedEntities = new HashSet<String>(); |
| 17 |
} |
| 18 |
|
| 19 |
public DtdContext(DtdContext dc) { |
| 20 |
notations = dc.notations; |
| 21 |
unparsedEntities = dc.unparsedEntities; |
| 22 |
} |
| 23 |
|
| 24 |
public void notationDecl(String name, |
| 25 |
String publicId, |
| 26 |
String systemId) |
| 27 |
throws SAXException { |
| 28 |
notations.add(name); |
| 29 |
} |
| 30 |
|
| 31 |
public void unparsedEntityDecl(String name, |
| 32 |
String publicId, |
| 33 |
String systemId, |
| 34 |
String notationName) |
| 35 |
throws SAXException { |
| 36 |
unparsedEntities.add(name); |
| 37 |
} |
| 38 |
|
| 39 |
public boolean isNotation(String notationName) { |
| 40 |
return notations.contains(notationName); |
| 41 |
} |
| 42 |
|
| 43 |
public boolean isUnparsedEntity(String entityName) { |
| 44 |
return unparsedEntities.contains(entityName); |
| 45 |
} |
| 46 |
|
| 47 |
public void clearDtdContext() { |
| 48 |
notations.clear(); |
| 49 |
unparsedEntities.clear(); |
| 50 |
} |
| 51 |
} |