KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > ext > report > DocBookFilterReader


1 /* ====================================================================
2  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3  *
4  * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by Jcorporate Ltd.
21  * (http://www.jcorporate.com/)."
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. "Jcorporate" and product names such as "Expresso" must
26  * not be used to endorse or promote products derived from this
27  * software without prior written permission. For written permission,
28  * please contact info@jcorporate.com.
29  *
30  * 5. Products derived from this software may not be called "Expresso",
31  * or other Jcorporate product names; nor may "Expresso" or other
32  * Jcorporate product names appear in their name, without prior
33  * written permission of Jcorporate Ltd.
34  *
35  * 6. No product derived from this software may compete in the same
36  * market space, i.e. framework, without prior written permission
37  * of Jcorporate Ltd. For written permission, please contact
38  * partners@jcorporate.com.
39  *
40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43  * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
44  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
46  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * ====================================================================
53  *
54  * This software consists of voluntary contributions made by many
55  * individuals on behalf of the Jcorporate Ltd. Contributions back
56  * to the project(s) are encouraged when you make modifications.
57  * Please send them to support@jcorporate.com. For more information
58  * on Jcorporate Ltd. and its products, please see
59  * <http://www.jcorporate.com/>.
60  *
61  * Portions of this software are based upon other open source
62  * products and are subject to their respective licenses.
63  */

64
65 package com.jcorporate.expresso.ext.report;
66
67
68 import java.io.FilterReader JavaDoc;
69 import java.io.IOException JavaDoc;
70 import java.io.PushbackReader JavaDoc;
71 import java.io.Reader JavaDoc;
72 import java.util.HashMap JavaDoc;
73 import java.util.Map JavaDoc;
74
75 /**
76  * A FilterReader that understands the docbook entities and converts them to
77  * their character codes. This class is not threadsafe within a single instance
78  * and care should be taken.
79  *
80  * @author David Lloyd
81  */

82
83 public class DocBookFilterReader extends FilterReader JavaDoc {
84
85     /**
86      * The buffer holding characters read after an amperstand that may be an entity.
87      */

88     private char[] lookahead = new char[32];
89
90     /**
91      * The buffer holding characters to be read out first.
92      */

93     private char[] pushahead = new char[32];
94     private int pushaheadOffset = 0;
95     private int pushaheadLen = 0;
96
97     /**
98      * Map entity to character code.
99      */

100     private static Map JavaDoc entities = new HashMap JavaDoc();
101
102     static {
103         loadEntites(entities);
104     }
105
106     /**
107      * Create the reader on a stream.
108      *
109      * @param in The underlying input stream.
110      */

111     public DocBookFilterReader(Reader JavaDoc in) {
112         super(new PushbackReader JavaDoc(in, 32));
113     }
114
115     /**
116      * Override from Reader.
117      */

118     public int read() throws IOException JavaDoc {
119         int ch;
120         
121         // return any pending characters first
122
if (pushaheadLen > 0) {
123             ch = pushahead[pushaheadOffset++];
124             pushaheadLen--;
125         } else {
126             do {
127                 ch = in.read();
128             } while (ch == 0);
129
130             if (ch == '&') {
131                 // see if we have an entity
132

133                 int ch2 = -1;
134                 int n = 0;
135                 lookahead[n++] = (char) ch;
136
137                 while (n < lookahead.length) {
138                     ch2 = in.read();
139                     if (ch2 == -1) {
140                         break;
141                     }
142
143                     lookahead[n++] = (char) ch2;
144
145                     if (!Character.isLetterOrDigit((char) ch2)) {
146                         break;
147                     }
148                 }
149
150                 if (ch2 == ';') {
151                     // lookup the entity
152
ch2 = lookupEntityToChar(n);
153
154                     if (ch2 == -1)
155                     // no entity, put chars back for the next read
156
{
157                         ((PushbackReader JavaDoc) in).unread(lookahead, 1, n - 1);
158                     } else
159                     // the lookup has filled the pushahead here's the first char
160
{
161                         ch = ch2;
162                     }
163                 } else {
164                     // does'nt seem to be an entity, put chars back for the next read
165
((PushbackReader JavaDoc) in).unread(lookahead, 1, n - 1);
166                 }
167             }
168         }
169         return ch;
170     }
171
172     /**
173      * Override from Reader.
174      */

175     public int read(char[] cbuf, int off, int len) throws IOException JavaDoc {
176         int nread = 0;
177         for (int i = off; nread < len; i++) {
178             int c = read();
179             if (c == -1) {
180                 break;
181             }
182             cbuf[i] = (char) c;
183             nread++;
184         }
185         if (nread == 0) {
186             return -1;
187         }
188         return nread;
189     }
190
191     /**
192      * Lookup the entity and return the first char.
193      *
194      * @param nlook The size of the lookahead buffer that contains the potential entity.
195      * @return The first char of the transformation or -1 on error.
196      * @postcondition The pushahead buffer is loaded with the full transformation.
197      */

198     private int lookupEntityToChar(int nlook) {
199         if (lookupEntity(nlook)) {
200             if (pushaheadLen > 0) {
201                 pushaheadLen--;
202                 return pushahead[pushaheadOffset++];
203             }
204         }
205         return -1;
206     }
207
208     /**
209      * Lookup the entity.
210      *
211      * @param nlook The size of the lookahead buffer that contains the potential entity.
212      * @return true if the entity was found.
213      * @postcondition The pushahead buffer is loaded with the full transformation.
214      */

215     private boolean lookupEntity(int nlook) {
216         String JavaDoc lookaheadStr = new String JavaDoc(lookahead, 0, nlook);
217         String JavaDoc entity = (String JavaDoc) entities.get(lookaheadStr);
218         if (entity != null) {
219             entity.getChars(0, entity.length(), pushahead, 0);
220             pushaheadOffset = 0;
221             pushaheadLen = entity.length();
222             return true;
223         }
224         return false;
225     }
226
227     private static void loadEntites(Map JavaDoc entities) {
228         entities.put("&half;", "&#x00BD;");
229         entities.put("&emsp;", "&#x2003;");
230         entities.put("&ensp;", "&#x2002;");
231         entities.put("&emsp13;", "&#x2004;");
232         entities.put("&emsp14;", "&#x2005;");
233         entities.put("&numsp;", "&#x2007;");
234         entities.put("&puncsp;", "&#x2008;");
235         entities.put("&thinsp;", "&#x2009;");
236         entities.put("&hairsp;", "&#x200A;");
237         entities.put("&mdash;", "&#x2014;");
238         entities.put("&ndash;", "&#x2013;");
239         entities.put("&dash;", "&#x2010;");
240         entities.put("&blank;", "&#x2423;");
241         entities.put("&hellip;", "&#x2026;");
242         entities.put("&nldr;", "&#x2025;");
243         entities.put("&frac13;", "&#x2153;");
244         entities.put("&frac23;", "&#x2154;");
245         entities.put("&frac15;", "&#x2155;");
246         entities.put("&frac25;", "&#x2156;");
247         entities.put("&frac35;", "&#x2157;");
248         entities.put("&frac45;", "&#x2158;");
249         entities.put("&frac16;", "&#x2159;");
250         entities.put("&frac56;", "&#x215A;");
251         entities.put("&incare;", "&#x2105;");
252         entities.put("&block;", "&#x2588;");
253         entities.put("&uhblk;", "&#x2580;");
254         entities.put("&lhblk;", "&#x2584;");
255         entities.put("&blk14;", "&#x2591;");
256         entities.put("&blk12;", "&#x2592;");
257         entities.put("&blk34;", "&#x2593;");
258         entities.put("&marker;", "&#x25AE;");
259         entities.put("&cir;", "&#x25CB;");
260         entities.put("&squ;", "&#x25A1;");
261         entities.put("&rect;", "&#x25AD;");
262         entities.put("&utri;", "&#x25B5;");
263         entities.put("&dtri;", "&#x25BF;");
264         entities.put("&star;", "&#x22C6;");
265         entities.put("&bull;", "&#x2022;");
266         entities.put("&squf;", "&#x25AA;");
267         entities.put("&utrif;", "&#x25B4;");
268         entities.put("&dtrif;", "&#x25BE;");
269         entities.put("&ltrif;", "&#x25C2;");
270         entities.put("&rtrif;", "&#x25B8;");
271         entities.put("&clubs;", "&#x2663;");
272         entities.put("&diams;", "&#x2666;");
273         entities.put("&hearts;", "&#x2665;");
274         entities.put("&spades;", "&#x2660;");
275         entities.put("&malt;", "&#x2720;");
276         entities.put("&dagger;", "&#x2020;");
277         entities.put("&Dagger;", "&#x2021;");
278         entities.put("&check;", "&#x2713;");
279         entities.put("&cross;", "&#x2717;");
280         entities.put("&sharp;", "&#x266F;");
281         entities.put("&flat;", "&#x266D;");
282         entities.put("&male;", "&#x2642;");
283         entities.put("&female;", "&#x2640;");
284         entities.put("&phone;", "&#x260E;");
285         entities.put("&telrec;", "&#x2315;");
286         entities.put("&copysr;", "&#x2117;");
287         entities.put("&caret;", "&#x2041;");
288         entities.put("&lsquor;", "&#x201A;");
289         entities.put("&ldquor;", "&#x201E;");
290         entities.put("&fflig;", "&#xFB00;");
291         entities.put("&filig;", "&#xFB01;");
292         entities.put("&ffilig;", "&#xFB03;");
293         entities.put("&ffllig;", "&#xFB04;");
294         entities.put("&fllig;", "&#xFB02;");
295         entities.put("&mldr;", "&#x2026;");
296         entities.put("&rdquor;", "&#x201C;");
297         entities.put("&rsquor;", "&#x2018;");
298         entities.put("&vellip;", "&#x22EE;");
299         entities.put("&hybull;", "&#x2043;");
300         entities.put("&loz;", "&#x25CA;");
301         entities.put("&lozf;", "&#x2726;");
302         entities.put("&ltri;", "&#x25C3;");
303         entities.put("&rtri;", "&#x25B9;");
304         entities.put("&starf;", "&#x2605;");
305         entities.put("&natur;", "&#x266E;");
306         entities.put("&rx;", "&#x211E;");
307         entities.put("&sext;", "&#x2736;");
308         entities.put("&target;", "&#x2316;");
309         entities.put("&dlcrop;", "&#x230D;");
310         entities.put("&drcrop;", "&#x230C;");
311         entities.put("&ulcrop;", "&#x230F;");
312         entities.put("&urcrop;", "&#x230E;");
313         entities.put("&agr;", "&#x03B1;");
314         entities.put("&Agr;", "&#x0391;");
315         entities.put("&bgr;", "&#x03B2;");
316         entities.put("&Bgr;", "&#x0392;");
317         entities.put("&ggr;", "&#x03B3;");
318         entities.put("&Ggr;", "&#x0393;");
319         entities.put("&dgr;", "&#x03B4;");
320         entities.put("&Dgr;", "&#x0394;");
321         entities.put("&egr;", "&#x03B5;");
322         entities.put("&Egr;", "&#x0395;");
323         entities.put("&zgr;", "&#x03B6;");
324         entities.put("&Zgr;", "&#x0396;");
325         entities.put("&eegr;", "&#x03B7;");
326         entities.put("&EEgr;", "&#x0397;");
327         entities.put("&thgr;", "&#x03B8;");
328         entities.put("&THgr;", "&#x0398;");
329         entities.put("&igr;", "&#x03B9;");
330         entities.put("&Igr;", "&#x0399;");
331         entities.put("&kgr;", "&#x03BA;");
332         entities.put("&Kgr;", "&#x039A;");
333         entities.put("&lgr;", "&#x03BB;");
334         entities.put("&Lgr;", "&#x039B;");
335         entities.put("&mgr;", "&#x03BC;");
336         entities.put("&Mgr;", "&#x039C;");
337         entities.put("&ngr;", "&#x03BD;");
338         entities.put("&Ngr;", "&#x039D;");
339         entities.put("&xgr;", "&#x03BE;");
340         entities.put("&Xgr;", "&#x039E;");
341         entities.put("&ogr;", "&#x03BF;");
342         entities.put("&Ogr;", "&#x039F;");
343         entities.put("&pgr;", "&#x03C0;");
344         entities.put("&Pgr;", "&#x03A0;");
345         entities.put("&rgr;", "&#x03C1;");
346         entities.put("&Rgr;", "&#x03A1;");
347         entities.put("&sgr;", "&#x03C3;");
348         entities.put("&Sgr;", "&#x03A3;");
349         entities.put("&sfgr;", "&#x03C2;");
350         entities.put("&tgr;", "&#x03C4;");
351         entities.put("&Tgr;", "&#x03A4;");
352         entities.put("&ugr;", "&#x03C5;");
353         entities.put("&Ugr;", "&#x03A5;");
354         entities.put("&phgr;", "&#x03C6;");
355         entities.put("&PHgr;", "&#x03A6;");
356         entities.put("&khgr;", "&#x03C7;");
357         entities.put("&KHgr;", "&#x03A7;");
358         entities.put("&psgr;", "&#x03C8;");
359         entities.put("&PSgr;", "&#x03A8;");
360         entities.put("&ohgr;", "&#x03C9;");
361         entities.put("&OHgr;", "&#x03A9;");
362         entities.put("&aacgr;", "&#x03AC;");
363         entities.put("&Aacgr;", "&#x0386;");
364         entities.put("&eacgr;", "&#x03AD;");
365         entities.put("&Eacgr;", "&#x0388;");
366         entities.put("&eeacgr;", "&#x03AE;");
367         entities.put("&EEacgr;", "&#x0389;");
368         entities.put("&idigr;", "&#x03CA;");
369         entities.put("&Idigr;", "&#x03AA;");
370         entities.put("&iacgr;", "&#x03AF;");
371         entities.put("&Iacgr;", "&#x038A;");
372         entities.put("&idiagr;", "&#x0390;");
373         entities.put("&oacgr;", "&#x03CC;");
374         entities.put("&Oacgr;", "&#x038C;");
375         entities.put("&udigr;", "&#x03CB;");
376         entities.put("&Udigr;", "&#x03AB;");
377         entities.put("&uacgr;", "&#x03CD;");
378         entities.put("&Uacgr;", "&#x038E;");
379         entities.put("&udiagr;", "&#x03B0;");
380         entities.put("&ohacgr;", "&#x03CE;");
381         entities.put("&OHacgr;", "&#x038F;");
382         entities.put("&alpha;", "&#x03B1;");
383         entities.put("&beta;", "&#x03B2;");
384         entities.put("&gamma;", "&#x03B3;");
385         entities.put("&Gamma;", "&#x0393;");
386         entities.put("&gammad;", "&#x03DC;");
387         entities.put("&delta;", "&#x03B4;");
388         entities.put("&Delta;", "&#x0394;");
389         entities.put("&epsi;", "&#x220A;");
390         entities.put("&epsiv;", "&#x03B5;");
391         entities.put("&epsis;", "&#x220A;");
392         entities.put("&zeta;", "&#x03B6;");
393         entities.put("&eta;", "&#x03B7;");
394         entities.put("&thetas;", "&#x03B8;");
395         entities.put("&Theta;", "&#x0398;");
396         entities.put("&thetav;", "&#x03D1;");
397         entities.put("&iota;", "&#x03B9;");
398         entities.put("&kappa;", "&#x03BA;");
399         entities.put("&kappav;", "&#x03F0;");
400         entities.put("&lambda;", "&#x03BB;");
401         entities.put("&Lambda;", "&#x039B;");
402         entities.put("&mu;", "&#x03BC;");
403         entities.put("&nu;", "&#x03BD;");
404         entities.put("&xi;", "&#x03BE;");
405         entities.put("&Xi;", "&#x039E;");
406         entities.put("&pi;", "&#x03C0;");
407         entities.put("&piv;", "&#x03D6;");
408         entities.put("&Pi;", "&#x03A0;");
409         entities.put("&rho;", "&#x03C1;");
410         entities.put("&rhov;", "&#x03F1;");
411         entities.put("&sigma;", "&#x03C3;");
412         entities.put("&Sigma;", "&#x03A3;");
413         entities.put("&sigmav;", "&#x03C2;");
414         entities.put("&tau;", "&#x03C4;");
415         entities.put("&upsi;", "&#x03C5;");
416         entities.put("&Upsi;", "&#x03D2;");
417         entities.put("&phis;", "&#x03C6;");
418         entities.put("&Phi;", "&#x03A6;");
419         entities.put("&phiv;", "&#x03D5;");
420         entities.put("&chi;", "&#x03C7;");
421         entities.put("&psi;", "&#x03C8;");
422         entities.put("&Psi;", "&#x03A8;");
423         entities.put("&omega;", "&#x03C9;");
424         entities.put("&Omega;", "&#x03A9;");
425         entities.put("&b.alpha;", "&#x03B1;");
426         entities.put("&b.beta;", "&#x03B2;");
427         entities.put("&b.gamma;", "&#x03B3;");
428         entities.put("&b.Gamma;", "&#x0393;");
429         entities.put("&b.gammad;", "&#x03DC;");
430         entities.put("&b.delta;", "&#x03B4;");
431         entities.put("&b.Delta;", "&#x0394;");
432         entities.put("&b.epsi;", "&#x03B5;");
433         entities.put("&b.epsiv;", "&#x03B5;");
434         entities.put("&b.epsis;", "&#x03B5;");
435         entities.put("&b.zeta;", "&#x03B6;");
436         entities.put("&b.eta;", "&#x03B7;");
437         entities.put("&b.thetas;", "&#x03B8;");
438         entities.put("&b.Theta;", "&#x0398;");
439         entities.put("&b.thetav;", "&#x03D1;");
440         entities.put("&b.iota;", "&#x03B9;");
441         entities.put("&b.kappa;", "&#x03BA;");
442         entities.put("&b.kappav;", "&#x03F0;");
443         entities.put("&b.lambda;", "&#x03BB;");
444         entities.put("&b.Lambda;", "&#x039B;");
445         entities.put("&b.mu;", "&#x03BC;");
446         entities.put("&b.nu;", "&#x03BD;");
447         entities.put("&b.xi;", "&#x03BE;");
448         entities.put("&b.Xi;", "&#x039E;");
449         entities.put("&b.pi;", "&#x03C0;");
450         entities.put("&b.Pi;", "&#x03A0;");
451         entities.put("&b.piv;", "&#x03D6;");
452         entities.put("&b.rho;", "&#x03C1;");
453         entities.put("&b.rhov;", "&#x03F1;");
454         entities.put("&b.sigma;", "&#x03C3;");
455         entities.put("&b.Sigma;", "&#x03A3;");
456         entities.put("&b.sigmav;", "&#x03C2;");
457         entities.put("&b.tau;", "&#x03C4;");
458         entities.put("&b.upsi;", "&#x03C5;");
459         entities.put("&b.Upsi;", "&#x03D2;");
460         entities.put("&b.phis;", "&#x03C6;");
461         entities.put("&b.Phi;", "&#x03A6;");
462         entities.put("&b.phiv;", "&#x03D5;");
463         entities.put("&b.chi;", "&#x03C7;");
464         entities.put("&b.psi;", "&#x03C8;");
465         entities.put("&b.Psi;", "&#x03A8;");
466         entities.put("&b.omega;", "&#x03C9;");
467         entities.put("&b.Omega;", "&#x03A9;");
468         entities.put("&aacute;", "&#x00E1;");
469         entities.put("&Aacute;", "&#x00C1;");
470         entities.put("&acirc;", "&#x00E2;");
471         entities.put("&Acirc;", "&#x00C2;");
472         entities.put("&agrave;", "&#x00E0;");
473         entities.put("&Agrave;", "&#x00C0;");
474         entities.put("&aring;", "&#x00E5;");
475         entities.put("&Aring;", "&#x00C5;");
476         entities.put("&atilde;", "&#x00E3;");
477         entities.put("&Atilde;", "&#x00C3;");
478         entities.put("&auml;", "&#x00E4;");
479         entities.put("&Auml;", "&#x00C4;");
480         entities.put("&aelig;", "&#x00E6;");
481         entities.put("&AElig;", "&#x00C6;");
482         entities.put("&ccedil;", "&#x00E7;");
483         entities.put("&Ccedil;", "&#x00C7;");
484         entities.put("&eth;", "&#x00D0;");
485         entities.put("&ETH;", "&#x00F0;");
486         entities.put("&eacute;", "&#x00E9;");
487         entities.put("&Eacute;", "&#x00C9;");
488         entities.put("&ecirc;", "&#x00EA;");
489         entities.put("&Ecirc;", "&#x00CA;");
490         entities.put("&egrave;", "&#x00E8;");
491         entities.put("&Egrave;", "&#x00C8;");
492         entities.put("&euml;", "&#x00EB;");
493         entities.put("&Euml;", "&#x00CB;");
494         entities.put("&iacute;", "&#x00ED;");
495         entities.put("&Iacute;", "&#x00CD;");
496         entities.put("&icirc;", "&#x00EE;");
497         entities.put("&Icirc;", "&#x00CE;");
498         entities.put("&igrave;", "&#x00EC;");
499         entities.put("&Igrave;", "&#x00CC;");
500         entities.put("&iuml;", "&#x00EF;");
501         entities.put("&Iuml;", "&#x00CF;");
502         entities.put("&ntilde;", "&#x00F1;");
503         entities.put("&Ntilde;", "&#x00D1;");
504         entities.put("&oacute;", "&#x00F3;");
505         entities.put("&Oacute;", "&#x00D3;");
506         entities.put("&ocirc;", "&#x00F4;");
507         entities.put("&Ocirc;", "&#x00D4;");
508         entities.put("&ograve;", "&#x00F2;");
509         entities.put("&Ograve;", "&#x00D2;");
510         entities.put("&oslash;", "&#x2298;");
511         entities.put("&Oslash;", "&#x00D8;");
512         entities.put("&otilde;", "&#x00F5;");
513         entities.put("&Otilde;", "&#x00D5;");
514         entities.put("&ouml;", "&#x00F6;");
515         entities.put("&Ouml;", "&#x00D6;");
516         entities.put("&szlig;", "&#x00DF;");
517         entities.put("&thorn;", "&#x00FE;");
518         entities.put("&THORN;", "&#x00DE;");
519         entities.put("&uacute;", "&#x00FA;");
520         entities.put("&Uacute;", "&#x00DA;");
521         entities.put("&ucirc;", "&#x00DB;");
522         entities.put("&Ucirc;", "&#x00FB;");
523         entities.put("&ugrave;", "&#x00F9;");
524         entities.put("&Ugrave;", "&#x00D9;");
525         entities.put("&uuml;", "&#x00FC;");
526         entities.put("&Uuml;", "&#x00DC;");
527         entities.put("&yacute;", "&#x00FD;");
528         entities.put("&Yacute;", "&#x00DD;");
529         entities.put("&yuml;", "&#x00FF;");
530         entities.put("&abreve;", "&#x0103;");
531         entities.put("&Abreve;", "&#x0102;");
532         entities.put("&amacr;", "&#x0101;");
533         entities.put("&Amacr;", "&#x0100;");
534         entities.put("&aogon;", "&#x0105;");
535         entities.put("&Aogon;", "&#x0104;");
536         entities.put("&cacute;", "&#x0107;");
537         entities.put("&Cacute;", "&#x0106;");
538         entities.put("&ccaron;", "&#x010D;");
539         entities.put("&Ccaron;", "&#x010C;");
540         entities.put("&ccirc;", "&#x0109;");
541         entities.put("&Ccirc;", "&#x0108;");
542         entities.put("&cdot;", "&#x22C5;");
543         entities.put("&Cdot;", "&#x010A;");
544         entities.put("&dcaron;", "&#x010F;");
545         entities.put("&Dcaron;", "&#x010E;");
546         entities.put("&dstrok;", "&#x0111;");
547         entities.put("&Dstrok;", "&#x0110;");
548         entities.put("&ecaron;", "&#x011B;");
549         entities.put("&Ecaron;", "&#x011A;");
550         entities.put("&edot;", "&#x0117;");
551         entities.put("&Edot;", "&#x0116;");
552         entities.put("&emacr;", "&#x0113;");
553         entities.put("&Emacr;", "&#x0112;");
554         entities.put("&eogon;", "&#x0119;");
555         entities.put("&Eogon;", "&#x0118;");
556         entities.put("&gacute;", "&#x01F5;");
557         entities.put("&gbreve;", "&#x011F;");
558         entities.put("&Gbreve;", "&#x011E;");
559         entities.put("&Gcedil;", "&#x0122;");
560         entities.put("&gcirc;", "&#x011D;");
561         entities.put("&Gcirc;", "&#x011C;");
562         entities.put("&gdot;", "&#x0121;");
563         entities.put("&Gdot;", "&#x0120;");
564         entities.put("&hcirc;", "&#x0125;");
565         entities.put("&Hcirc;", "&#x0124;");
566         entities.put("&hstrok;", "&#x0127;");
567         entities.put("&Hstrok;", "&#x0126;");
568         entities.put("&Idot;", "&#x0130;");
569         entities.put("&Imacr;", "&#x012A;");
570         entities.put("&imacr;", "&#x012B;");
571         entities.put("&ijlig;", "&#x0133;");
572         entities.put("&IJlig;", "&#x0132;");
573         entities.put("&inodot;", "&#x0131;");
574         entities.put("&iogon;", "&#x012F;");
575         entities.put("&Iogon;", "&#x012E;");
576         entities.put("&itilde;", "&#x0129;");
577         entities.put("&Itilde;", "&#x0128;");
578         entities.put("&jcirc;", "&#x0135;");
579         entities.put("&Jcirc;", "&#x0134;");
580         entities.put("&kcedil;", "&#x0137;");
581         entities.put("&Kcedil;", "&#x0136;");
582         entities.put("&kgreen;", "&#x0138;");
583         entities.put("&lacute;", "&#x013A;");
584         entities.put("&Lacute;", "&#x0139;");
585         entities.put("&lcaron;", "&#x013E;");
586         entities.put("&Lcaron;", "&#x013D;");
587         entities.put("&lcedil;", "&#x013C;");
588         entities.put("&Lcedil;", "&#x013B;");
589         entities.put("&lmidot;", "&#x0140;");
590         entities.put("&Lmidot;", "&#x013F;");
591         entities.put("&lstrok;", "&#x0142;");
592         entities.put("&Lstrok;", "&#x0141;");
593         entities.put("&nacute;", "&#x0144;");
594         entities.put("&Nacute;", "&#x0143;");
595         entities.put("&eng;", "&#x014B;");
596         entities.put("&ENG;", "&#x014A;");
597         entities.put("&napos;", "&#x0149;");
598         entities.put("&ncaron;", "&#x0148;");
599         entities.put("&Ncaron;", "&#x0147;");
600         entities.put("&ncedil;", "&#x0146;");
601         entities.put("&Ncedil;", "&#x0145;");
602         entities.put("&odblac;", "&#x0151;");
603         entities.put("&Odblac;", "&#x0150;");
604         entities.put("&Omacr;", "&#x014C;");
605         entities.put("&omacr;", "&#x014D;");
606         entities.put("&oelig;", "&#x0153;");
607         entities.put("&OElig;", "&#x0152;");
608         entities.put("&racute;", "&#x0155;");
609         entities.put("&Racute;", "&#x0154;");
610         entities.put("&rcaron;", "&#x0159;");
611         entities.put("&Rcaron;", "&#x0158;");
612         entities.put("&rcedil;", "&#x0157;");
613         entities.put("&Rcedil;", "&#x0156;");
614         entities.put("&sacute;", "&#x015B;");
615         entities.put("&Sacute;", "&#x015A;");
616         entities.put("&scaron;", "&#x0161;");
617         entities.put("&Scaron;", "&#x0160;");
618         entities.put("&scedil;", "&#x015F;");
619         entities.put("&Scedil;", "&#x015E;");
620         entities.put("&scirc;", "&#x015D;");
621         entities.put("&Scirc;", "&#x015C;");
622         entities.put("&tcaron;", "&#x0165;");
623         entities.put("&Tcaron;", "&#x0164;");
624         entities.put("&tcedil;", "&#x0163;");
625         entities.put("&Tcedil;", "&#x0162;");
626         entities.put("&tstrok;", "&#x0167;");
627         entities.put("&Tstrok;", "&#x0166;");
628         entities.put("&ubreve;", "&#x016D;");
629         entities.put("&Ubreve;", "&#x016C;");
630         entities.put("&udblac;", "&#x0171;");
631         entities.put("&Udblac;", "&#x0170;");
632         entities.put("&umacr;", "&#x016B;");
633         entities.put("&Umacr;", "&#x016A;");
634         entities.put("&uogon;", "&#x0173;");
635         entities.put("&Uogon;", "&#x0172;");
636         entities.put("&uring;", "&#x016F;");
637         entities.put("&Uring;", "&#x016E;");
638         entities.put("&utilde;", "&#x0169;");
639         entities.put("&Utilde;", "&#x0168;");
640         entities.put("&wcirc;", "&#x0175;");
641         entities.put("&Wcirc;", "&#x0174;");
642         entities.put("&ycirc;", "&#x0177;");
643         entities.put("&Ycirc;", "&#x0176;");
644         entities.put("&Yuml;", "&#x0178;");
645         entities.put("&zacute;", "&#x017A;");
646         entities.put("&Zacute;", "&#x0179;");
647         entities.put("&zcaron;", "&#x017E;");
648         entities.put("&Zcaron;", "&#x017D;");
649         entities.put("&zdot;", "&#x017C;");
650         entities.put("&Zdot;", "&#x017B;");
651         entities.put("&aleph;", "&#x2135;");
652         entities.put("&and;", "&#x2227;");
653         entities.put("&ang90;", "&#x221F;");
654         entities.put("&angsph;", "&#x2222;");
655         entities.put("&ap;", "&#x2248;");
656         entities.put("&becaus;", "&#x2235;");
657         entities.put("&bottom;", "&#x22A5;");
658         entities.put("&cap;", "&#x2229;");
659         entities.put("&cong;", "&#x2245;");
660         entities.put("&conint;", "&#x222E;");
661         entities.put("&cup;", "&#x222A;");
662         entities.put("&equiv;", "&#x2261;");
663         entities.put("&exist;", "&#x2203;");
664         entities.put("&forall;", "&#x2200;");
665         entities.put("&fnof;", "&#x0192;");
666         entities.put("&ge;", "&#x2265;");
667         entities.put("&iff;", "&#xE365;");
668         entities.put("&infin;", "&#x221E;");
669         entities.put("&int;", "&#x222B;");
670         entities.put("&isin;", "&#x220A;");
671         entities.put("&lang;", "&#x3008;");
672         entities.put("&lArr;", "&#x21D0;");
673         entities.put("&le;", "&#x2264;");
674         entities.put("&minus;", "&#x2212;");
675         entities.put("&mnplus;", "&#x2213;");
676         entities.put("&nabla;", "&#x2207;");
677         entities.put("&ne;", "&#x2260;");
678         entities.put("&ni;", "&#x220D;");
679         entities.put("&or;", "&#x2228;");
680         entities.put("&par;", "&#x2225;");
681         entities.put("&part;", "&#x2202;");
682         entities.put("&permil;", "&#x2030;");
683         entities.put("&perp;", "&#x22A5;");
684         entities.put("&prime;", "&#x2032;");
685         entities.put("&Prime;", "&#x2033;");
686         entities.put("&prop;", "&#x221D;");
687         entities.put("&radic;", "&#x221A;");
688         entities.put("&rang;", "&#x3009;");
689         entities.put("&rArr;", "&#x21D2;");
690         entities.put("&sim;", "&#x223C;");
691         entities.put("&sime;", "&#x2243;");
692         entities.put("&square;", "&#x25A1;");
693         entities.put("&sub;", "&#x2282;");
694         entities.put("&sube;", "&#x2286;");
695         entities.put("&sup;", "&#x2283;");
696         entities.put("&supe;", "&#x2287;");
697