KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nwalsh > saxon > Windows1252


1 /* This file was kindly provided by Sectra AB, Sweden to DocBook community */
2 package com.nwalsh.saxon;
3
4 import com.icl.saxon.charcode.PluggableCharacterSet;
5
6 /**
7  *
8  * $Id: Windows1252.java,v 1.2 2004/11/30 09:55:33 xmldoc Exp $
9  *
10  * File: Windows1252CharacterSet.java
11  * Created: May 26 2004
12  * Author: Pontus Haglund
13  * Project: Venus
14  *
15  * This class extends Saxon 6.5.x with the windows-1252 character set.
16  *
17  * It is particularly useful when generating HTML Help for
18  * Western European Languages.
19  *
20  * To use this class for generating HTML Help output with the
21  * DocBook XSL stylesheets, complete the following steps;
22  *
23  * 1. Make sure that the Saxon 6.5.x jar file and the jar file for
24  * the DocBook XSL Java extensions are in your CLASSPATH
25  *
26  * 2. Create a DocBook XSL customization layer -- a file named
27  * "mystylesheet.xsl" or whatever -- that, at a minimum,
28  * contains the following:
29  *
30  * <xsl:stylesheet
31  * xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
32  * version='1.0'>
33  * <xsl:import HREF="http://docbook.sourceforge.net/release/xsl/current/htmlhelp/htmlhelp.xsl"/>
34  * <xsl:output method="html" encoding="WINDOWS-1252" indent="no"/>
35  * <xsl:param name="htmlhelp.encoding" select="WINDOWS-1252"></xsl:param>
36  * <xsl:param name="chunker.output.encoding" select="WINDOWS-1252"></xsl:param>
37  * <xsl:param name="saxon.character.representation" select="native"></xsl:param>
38  * </xsl:stylesheet>
39  *
40  * 3. Invoke Saxon with the "encoding.windows-1252" Java system
41  * property set to "com.nwalsh.saxon.Windows1252"; for example:
42  *
43  * java \
44  * -Dencoding.windows-1252=com.nwalsh.saxon.Windows1252 \
45  * com.icl.saxon.StyleSheet \
46  * mydoc.xml mystylesheet.xsl
47  *
48  * Or, for a more complete "real world" case showing other
49  * options you'll typically want to use:
50  *
51  * java \
52  * -Dencoding.windows-1252=com.nwalsh.saxon.Windows1252 \
53  * -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl \
54  * -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl \
55  * -Djavax.xml.transform.TransformerFactory=com.icl.saxon.TransformerFactoryImpl \
56  * com.icl.saxon.StyleSheet \
57  * -x org.apache.xml.resolver.tools.ResolvingXMLReader \
58  * -y org.apache.xml.resolver.tools.ResolvingXMLReader \
59  * -r org.apache.xml.resolver.tools.CatalogResolver \
60  * mydoc.xml mystylesheet.xsl
61  *
62  * In both cases, the "mystylesheet.xsl" file should be a DocBook
63  * customization layer containing the parameters show in step 2.
64  *
65  */

66
67
68
69 public class Windows1252 implements PluggableCharacterSet {
70
71     public final boolean inCharset(int c) {
72
73     return (c >= 0x00 && c <= 0x7F) ||
74             (c >= 0xA0 && c <= 0xFF) ||
75             (c == 0x20AC) ||
76             (c == 0x201A) ||
77             (c == 0x0192) ||
78             (c == 0x201E) ||
79             (c == 0x2026) ||
80             (c == 0x2020) ||
81             (c == 0x2021) ||
82             (c == 0x02C6) ||
83             (c == 0x2030) ||
84             (c == 0x0160) ||
85             (c == 0x2039) ||
86             (c == 0x0152) ||
87             (c == 0x017D) ||
88             (c == 0x2018) ||
89             (c == 0x2019) ||
90             (c == 0x201C) ||
91             (c == 0x201D) ||
92             (c == 0x2022) ||
93             (c == 0x2013) ||
94             (c == 0x2014) ||
95             (c == 0x02DC) ||
96             (c == 0x2122) ||
97             (c == 0x0161) ||
98             (c == 0x203A) ||
99             (c == 0x0153) ||
100             (c == 0x017E) ||
101             (c == 0x0178);
102
103
104     }
105
106     public String JavaDoc getEncodingName() {
107         return "WINDOWS-1252";
108     }
109
110 }
111
Popular Tags