com.isogen.saxoni18n
Class Saxoni18nService

java.lang.Object
  extended bycom.isogen.saxoni18n.Saxoni18nService

public class Saxoni18nService
extends java.lang.Object

Binds the relevant methods of the generic I18nService class to the Saxon's extension function API to provide a set of XSLT extension functions. These functions provide support for both static ("generated") text management and index configuration and collation management. These functions can be used independently. By default, the index configuration and static text database files are in a directory called "config/" under the directory specified in the com.innodata.i18n.home Java system variable. The default configuration files are:

The locations of these files can be set using the following system properties: If either of these is set to the value "#none" then the library will not attempt to load the file. Use this file if you are not using a particular configuration file. In addition, the class attempts to load the properties in the file "config/properties/isogen_i18n.properties". If this file is present, any properties set in this file will be set as System properties for the JVM.

Version:
$Revision: 1.3 $

Field Summary
static I18nService i18nServer
           
 
Constructor Summary
Saxoni18nService()
           
 
Method Summary
static java.lang.String constructTargetRelativePath(java.lang.String origPathStr, java.lang.String targetBasePathStr)
           
static java.lang.String escapeUnicodeString(java.lang.String inStr)
           
static java.lang.String getAbsolutePath(java.lang.String basePath, java.lang.String relativePath)
           
static java.lang.String getAttributeTranslation(SingletonNodeSet sns, java.lang.String attname)
          Returns translated presentation value for the specified attribute of the specified element.
static java.lang.String getBaseName(java.lang.String inPath)
          Returns the filename part of a file path, with no extension
static java.util.Comparator getComparatorForLanguageCode(java.lang.String langCode)
          Given an language code, returns a Comparator for that language.
 java.lang.Class getExtensionClass(java.lang.String localname)
          Called by Saxon's extention element mechanism to request classes for extension elements.
static java.lang.String getFileDir(java.lang.String filePath)
           
static java.lang.String getFilename(java.lang.String inPath)
          Returns the filename part of a file path.
static java.lang.String getGeneratedTextAfter(SingletonNodeSet sns)
          Returns the text-after generated text for the element, if any.
static java.lang.String getGeneratedTextBefore(SingletonNodeSet sns, java.lang.String langCode)
          Returns the text-before generated text for the element, if any.
static java.lang.String getGeneratedTextForKeyAfter(java.lang.String key, java.lang.String langCode)
          Returns the text-before generated text for an arbitrary key, if any.
static java.lang.String getGeneratedTextForKeyBefore(java.lang.String key, java.lang.String langCode)
          Returns the text-before generated text for an arbitrary key, if any.
static java.lang.String getIndexGroupKey(java.lang.String langCode, java.lang.String indexEntry)
          Given an element with PCData content, returns the index group key string it should be grouped with.
static java.lang.String getIndexGroupLabel(java.lang.String langCode, java.lang.String groupKey)
          Given the string key for an index group, returns the display label for that group.
static java.lang.String getIndexGroupSortKey(java.lang.String langCode, java.lang.String groupKey)
           
static java.lang.String getIndexRulesFileName()
          Returns the filename used to load the index rules.
static java.lang.String getParaGeneratedTextAfter(SingletonNodeSet sns)
          Returns the text-after generated text for para elements.
static java.lang.String getParaGeneratedTextBefore(SingletonNodeSet sns)
          Returns the text-before generated text for para elements.
static java.lang.String getRelativePath(java.lang.String filePath, java.lang.String targetPath)
          Returns the relative from targetPath to filePath.
static java.lang.String getStaticTextDatabaseFileName()
          Returns the filename used to load the static text database.
static java.lang.String getTimeStamp()
          Returns the current system date and time as a string.
static java.lang.String getUrlPart(java.lang.String inUrl, java.lang.String partName)
           
static java.lang.String getVersionAndRelease()
           
static void main(java.lang.String[] args)
           
static java.lang.String printIndexConfiguration(java.lang.String langCode)
           
static java.lang.String printIndexConfiguration(java.lang.String langCode, boolean includeCollationRules)
           
static java.lang.String printStaticTextDatabase()
           
static boolean urlHasProtocol(java.lang.String inUrl)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

i18nServer

public static I18nService i18nServer
Constructor Detail

Saxoni18nService

public Saxoni18nService()
                 throws javax.xml.transform.TransformerConfigurationException
Method Detail

getExtensionClass

public java.lang.Class getExtensionClass(java.lang.String localname)
Called by Saxon's extention element mechanism to request classes for extension elements. The element element name is the classname. Names are case sensitive. This package does not provide any extension elements.


getGeneratedTextBefore

public static java.lang.String getGeneratedTextBefore(SingletonNodeSet sns,
                                                      java.lang.String langCode)
                                               throws XPathException
Returns the text-before generated text for the element, if any. Returns "" if there is no generated text or if the input node is not an element.

Parameters:
sns - Singleton Node Set, i.e., as provided by the "." expression.
Throws:
XPathException

getGeneratedTextForKeyBefore

public static java.lang.String getGeneratedTextForKeyBefore(java.lang.String key,
                                                            java.lang.String langCode)
                                                     throws XPathException
Returns the text-before generated text for an arbitrary key, if any. Returns "" if there is no generated text.

Parameters:
key - The string key to look up in the static text database.
Throws:
XPathException

getGeneratedTextForKeyAfter

public static java.lang.String getGeneratedTextForKeyAfter(java.lang.String key,
                                                           java.lang.String langCode)
                                                    throws XPathException
Returns the text-before generated text for an arbitrary key, if any. Returns "" if there is no generated text.

Parameters:
key - The string key to look up in the static text database.
Throws:
XPathException

getParaGeneratedTextBefore

public static java.lang.String getParaGeneratedTextBefore(SingletonNodeSet sns)
                                                   throws XPathException
Returns the text-before generated text for para elements.

Throws:
XPathException

getGeneratedTextAfter

public static java.lang.String getGeneratedTextAfter(SingletonNodeSet sns)
                                              throws XPathException
Returns the text-after generated text for the element, if any. Returns "" if there is no generated text or if the input node is not an element.

Parameters:
sns - Singleton Node Set, i.e., as provided by the "." expression.
Throws:
XPathException

getParaGeneratedTextAfter

public static java.lang.String getParaGeneratedTextAfter(SingletonNodeSet sns)
                                                  throws XPathException
Returns the text-after generated text for para elements.

Throws:
XPathException

getAttributeTranslation

public static java.lang.String getAttributeTranslation(SingletonNodeSet sns,
                                                       java.lang.String attname)
                                                throws XPathException
Returns translated presentation value for the specified attribute of the specified element.

Throws:
XPathException

getIndexGroupKey

public static java.lang.String getIndexGroupKey(java.lang.String langCode,
                                                java.lang.String indexEntry)
                                         throws XPathException
Given an element with PCData content, returns the index group key string it should be grouped with.

Parameters:
langCode - Language code for the index configuration to use.
indexEntry - Index entry value to the get the group key for.
Returns:
group key string
Throws:
XPathException

getIndexGroupSortKey

public static java.lang.String getIndexGroupSortKey(java.lang.String langCode,
                                                    java.lang.String groupKey)
                                             throws XPathException
Throws:
XPathException

getIndexGroupLabel

public static java.lang.String getIndexGroupLabel(java.lang.String langCode,
                                                  java.lang.String groupKey)
                                           throws XPathException
Given the string key for an index group, returns the display label for that group.

Throws:
XPathException

printStaticTextDatabase

public static java.lang.String printStaticTextDatabase()
                                                throws XPathException
Throws:
XPathException

printIndexConfiguration

public static java.lang.String printIndexConfiguration(java.lang.String langCode,
                                                       boolean includeCollationRules)
                                                throws XPathException
Throws:
XPathException

printIndexConfiguration

public static java.lang.String printIndexConfiguration(java.lang.String langCode)
                                                throws XPathException
Throws:
XPathException

getFileDir

public static java.lang.String getFileDir(java.lang.String filePath)

getUrlPart

public static java.lang.String getUrlPart(java.lang.String inUrl,
                                          java.lang.String partName)
                                   throws XPathException
Throws:
XPathException

urlHasProtocol

public static boolean urlHasProtocol(java.lang.String inUrl)
                              throws XPathException
Throws:
XPathException

escapeUnicodeString

public static java.lang.String escapeUnicodeString(java.lang.String inStr)
                                            throws XPathException
Throws:
XPathException

constructTargetRelativePath

public static java.lang.String constructTargetRelativePath(java.lang.String origPathStr,
                                                           java.lang.String targetBasePathStr)
                                                    throws XPathException
Throws:
XPathException

getFilename

public static java.lang.String getFilename(java.lang.String inPath)
                                    throws XPathException
Returns the filename part of a file path.

Parameters:
inPath -
Returns:
Filename part, including any extension.
Throws:
XPathException

getBaseName

public static java.lang.String getBaseName(java.lang.String inPath)
                                    throws XPathException
Returns the filename part of a file path, with no extension

Parameters:
inPath -
Returns:
Filename part, minus any extension
Throws:
XPathException

getTimeStamp

public static java.lang.String getTimeStamp()
Returns the current system date and time as a string.

Returns:
date and time string.

getRelativePath

public static java.lang.String getRelativePath(java.lang.String filePath,
                                               java.lang.String targetPath)
Returns the relative from targetPath to filePath.

Parameters:
filePath - The path the result is relative to. Must be an absolute path.
targetPath - The path the result is derived from. Must be an absolute path, otherwise it is returned immediately.
Returns:
The relative path, if any.

getAbsolutePath

public static java.lang.String getAbsolutePath(java.lang.String basePath,
                                               java.lang.String relativePath)

main

public static void main(java.lang.String[] args)

getComparatorForLanguageCode

public static java.util.Comparator getComparatorForLanguageCode(java.lang.String langCode)
Given an language code, returns a Comparator for that language.

Parameters:
langCode - language code, consisting of ISO 639 two-letter language code and, optionally, an ISO 3166 country code, separated by a hyphen ("-"), e.g., "ar", "zh-TW".
Returns:
Comparator object.

getVersionAndRelease

public static java.lang.String getVersionAndRelease()

getStaticTextDatabaseFileName

public static java.lang.String getStaticTextDatabaseFileName()
Returns the filename used to load the static text database.

Returns:
The filename, as a string

getIndexRulesFileName

public static java.lang.String getIndexRulesFileName()
Returns the filename used to load the index rules.

Returns:
The filename, as a string