1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.kathrynhuxtable.maven.plugins.htmlfiltersite;
19
20 import java.io.IOException;
21
22 import org.xml.sax.EntityResolver;
23 import org.xml.sax.InputSource;
24 import org.xml.sax.SAXException;
25
26
27
28
29 public class DTDHandler implements EntityResolver {
30
31
32
33
34 public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
35 if (publicId.equals("-//W3C//DTD XHTML 1.0 Strict//EN")) {
36 return inputSource("/xhtml/dtd/xhtml1-strict.dtd");
37 } else if (publicId.equals("-//W3C//DTD XHTML 1.0 Transitional//EN")) {
38 return inputSource("/xhtml/dtd/xhtml1-transitional.dtd");
39 } else if (publicId.equals("-//W3C//DTD XHTML 1.0 Frameset//EN")) {
40 return inputSource("/xhtml/dtd/xhtml1-frameset.dtd");
41 } else if (publicId.equals("-//W3C//ENTITIES Latin 1 for XHTML//EN")) {
42 return inputSource("/xhtml/dtd/xhtml-lat1.ent");
43 } else if (publicId.equals("-//W3C//ENTITIES Symbols for XHTML//EN")) {
44 return inputSource("/xhtml/dtd/xhtml-symbol.ent");
45 } else if (publicId.equals("-//W3C//ENTITIES Special for XHTML//EN")) {
46 return inputSource("/xhtml/dtd/xhtml-special.ent");
47 } else {
48 return null;
49 }
50 }
51
52
53
54
55
56
57
58
59 private InputSource inputSource(String resource) {
60 return new InputSource(DTDHandler.class.getResourceAsStream(resource));
61 }
62 }