01: /* This file was kindly provided by Sectra AB, Sweden to DocBook community */
02: package com.nwalsh.saxon;
03:
04: import com.icl.saxon.charcode.PluggableCharacterSet;
05:
06: /**
07: *
08: * $Id: Windows1252.java,v 1.1 2006-09-19 09:40:19 sinisa Exp $
09: *
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: public class Windows1252 implements PluggableCharacterSet {
68:
69: public final boolean inCharset(int c) {
70:
71: return (c >= 0x00 && c <= 0x7F) || (c >= 0xA0 && c <= 0xFF)
72: || (c == 0x20AC) || (c == 0x201A) || (c == 0x0192)
73: || (c == 0x201E) || (c == 0x2026) || (c == 0x2020)
74: || (c == 0x2021) || (c == 0x02C6) || (c == 0x2030)
75: || (c == 0x0160) || (c == 0x2039) || (c == 0x0152)
76: || (c == 0x017D) || (c == 0x2018) || (c == 0x2019)
77: || (c == 0x201C) || (c == 0x201D) || (c == 0x2022)
78: || (c == 0x2013) || (c == 0x2014) || (c == 0x02DC)
79: || (c == 0x2122) || (c == 0x0161) || (c == 0x203A)
80: || (c == 0x0153) || (c == 0x017E) || (c == 0x0178);
81:
82: }
83:
84: public String getEncodingName() {
85: return "WINDOWS-1252";
86: }
87:
88: }
|