1 package org.apache.maven.doxia.siterenderer;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.IOException;
23
24 import org.xml.sax.EntityResolver;
25 import org.xml.sax.InputSource;
26 import org.xml.sax.SAXException;
27
28
29
30
31
32
33
34 public class XhtmlEntityResolver
35 implements EntityResolver
36 {
37 private static final String XHTML_PUBLIC_ID = "-//W3C//DTD XHTML 1.0 Transitional//EN";
38 private static final String DTD = "/dtd/xhtml1-transitional.dtd";
39
40 private static final String LAT1_PUBLIC_ID = "-//W3C//ENTITIES Latin 1 for XHTML//EN";
41 private static final String LAT1 = "/dtd/xhtml-lat1.ent";
42
43 private static final String SYMBOL_PUBLIC_ID = "-//W3C//ENTITIES Symbols for XHTML//EN";
44 private static final String SYMBOL = "/dtd/xhtml-symbol.ent";
45
46 private static final String SPECIAL_PUBLIC_ID = "-//W3C//ENTITIES Special for XHTML//EN";
47 private static final String SPECIAL = "/dtd/xhtml-special.ent";
48
49
50
51 public InputSource resolveEntity( String publicId, String systemId )
52 throws SAXException, IOException
53 {
54 if ( publicId == null )
55 {
56 return null;
57 }
58
59 if ( publicId.equals( XHTML_PUBLIC_ID ) )
60 {
61 return new InputSource( XhtmlEntityResolver.class.getResourceAsStream( DTD ) );
62 }
63 else if ( publicId.equals( LAT1_PUBLIC_ID ) )
64 {
65 return new InputSource( XhtmlEntityResolver.class.getResourceAsStream( LAT1 ) );
66 }
67 else if ( publicId.equals( SYMBOL_PUBLIC_ID ) )
68 {
69 return new InputSource( XhtmlEntityResolver.class.getResourceAsStream( SYMBOL ) );
70 }
71 else if ( publicId.equals( SPECIAL_PUBLIC_ID ) )
72 {
73 return new InputSource( XhtmlEntityResolver.class.getResourceAsStream( SPECIAL ) );
74 }
75 else
76 {
77 return null;
78 }
79 }
80 }