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
39 private static final String DTD = "/dtd/xhtml1-transitional.dtd";
40
41 private static final String LAT1_PUBLIC_ID = "-//W3C//ENTITIES Latin 1 for XHTML//EN";
42
43 private static final String LAT1 = "/dtd/xhtml-lat1.ent";
44
45 private static final String SYMBOL_PUBLIC_ID = "-//W3C//ENTITIES Symbols for XHTML//EN";
46
47 private static final String SYMBOL = "/dtd/xhtml-symbol.ent";
48
49 private static final String SPECIAL_PUBLIC_ID = "-//W3C//ENTITIES Special for XHTML//EN";
50
51 private static final String SPECIAL = "/dtd/xhtml-special.ent";
52
53
54 public InputSource resolveEntity( String publicId, String systemId )
55 throws SAXException, IOException
56 {
57 if ( publicId == null )
58 {
59 return null;
60 }
61
62 if ( publicId.equals( XHTML_PUBLIC_ID ) )
63 {
64 return new InputSource( XhtmlEntityResolver.class.getResourceAsStream( DTD ) );
65 }
66 else if ( publicId.equals( LAT1_PUBLIC_ID ) )
67 {
68 return new InputSource( XhtmlEntityResolver.class.getResourceAsStream( LAT1 ) );
69 }
70 else if ( publicId.equals( SYMBOL_PUBLIC_ID ) )
71 {
72 return new InputSource( XhtmlEntityResolver.class.getResourceAsStream( SYMBOL ) );
73 }
74 else if ( publicId.equals( SPECIAL_PUBLIC_ID ) )
75 {
76 return new InputSource( XhtmlEntityResolver.class.getResourceAsStream( SPECIAL ) );
77 }
78 else
79 {
80 return null;
81 }
82 }
83 }