net.sf.saxon

Class JavaPlatform

public class JavaPlatform extends Object implements Platform

Implementation of the Platform class containing methods specific to the Java platform (as distinct from .NET)
Method Summary
booleancanReturnCollationKeys(Comparator collation)
Given a collation, determine whether it is capable of returning collation keys.
RegularExpressioncompileRegularExpression(CharSequence regex, boolean isXPath, CharSequence flags)
Create a compiled regular expression
static StringescapeSpaces(String s)
Replace spaces by %20
ObjectgetCollationKey(Comparator collation, String value)
Given a collation, get a collation key.
static JavaPlatformgetInstance()
SourcegetParserSource(StreamSource input, int validation, boolean dtdValidation, int stripspace)
Convert a StreamSource to either a SAXSource or a PullSource, depending on the native parser of the selected platform
StringgetPlatformSuffix()
Get a suffix letter to add to the Saxon version number to identify the platform
StringgetPlatformVersion()
Get the platform version
voidinitialize(Configuration config)
Perform platform-specific initialization of the configuration
URImakeAbsolute(String relativeURI, String base)
Construct an absolute URI from a relative URI and a base URI
ComparatormakeCollation(Configuration config, Properties props)
Obtain a collation with a given set of properties.
static StringtryToExpand(String systemId)
If a system ID can't be parsed as a URL, we'll try to expand it as a relative URI using the current directory as the base URI: MHK addition.

Method Detail

canReturnCollationKeys

public boolean canReturnCollationKeys(Comparator collation)
Given a collation, determine whether it is capable of returning collation keys. The essential property of collation keys is that if two values are equal under the collation, then the collation keys are equal under the equals() method.

Parameters: collation the collation, provided as a Comparator

Returns: true if this collation can supply collation keys

compileRegularExpression

public RegularExpression compileRegularExpression(CharSequence regex, boolean isXPath, CharSequence flags)
Create a compiled regular expression

Parameters: regex the source text of the regular expression, in XML Schema or XPath syntax isXPath set to true if this is an XPath regular expression, false if it is XML Schema flags the flags argument as supplied to functions such as fn:matches(), in string form

Returns: the compiled regular expression

Throws: XPathException if the syntax of the regular expression or flags is incorrect

escapeSpaces

public static String escapeSpaces(String s)
Replace spaces by %20

getCollationKey

public Object getCollationKey(Comparator collation, String value)
Given a collation, get a collation key. The essential property of collation keys is that if two values are equal under the collation, then the collation keys are compare correctly under the compareTo method.

Throws: ClassCastException if the collation is not one that is capable of supplying collation keys (this should have been checked in advance)

getInstance

public static JavaPlatform getInstance()

getParserSource

public Source getParserSource(StreamSource input, int validation, boolean dtdValidation, int stripspace)
Convert a StreamSource to either a SAXSource or a PullSource, depending on the native parser of the selected platform

Parameters: input the supplied StreamSource validation dtdValidation stripspace

Returns: the PullSource or SAXSource, initialized with a suitable parser, or the original input Source, if now special handling is required or possible. This implementation always returns the original input unchanged.

getPlatformSuffix

public String getPlatformSuffix()
Get a suffix letter to add to the Saxon version number to identify the platform

getPlatformVersion

public String getPlatformVersion()
Get the platform version

initialize

public void initialize(Configuration config)
Perform platform-specific initialization of the configuration

makeAbsolute

public URI makeAbsolute(String relativeURI, String base)
Construct an absolute URI from a relative URI and a base URI

Parameters: relativeURI the relative URI base the base URI

Returns: the absolutized URI

Throws: java.net.URISyntaxException

makeCollation

public Comparator makeCollation(Configuration config, Properties props)
Obtain a collation with a given set of properties. The set of properties is extensible and variable across platforms. Common properties with example values include lang=ed-GB, strength=primary, case-order=upper-first, ignore-modifiers=yes, alphanumeric=yes. Properties that are not supported are generally ignored; however some errors, such as failing to load a requested class, are fatal.

Parameters: config the configuration object props the desired properties of the collation

Returns: a collation with these properties

Throws: XPathException if a fatal error occurs

tryToExpand

public static String tryToExpand(String systemId)
If a system ID can't be parsed as a URL, we'll try to expand it as a relative URI using the current directory as the base URI: MHK addition.