Package net.sf.saxon.lib
Class ConversionRules
- java.lang.Object
-
- net.sf.saxon.lib.ConversionRules
-
- All Implemented Interfaces:
java.io.Serializable
public class ConversionRules extends java.lang.Object implements java.io.Serializable
This class defines a set of rules for converting between different atomic types. It handles the variations that arise between different versions of the W3C specifications, for example the changes in Name syntax between XML 1.0 and XML 1.1, the introduction of "+INF" as a permitted xs:double value in XSD 1.1, and so on.It is possible to nominate a customized
ConversionRules
object at the level of theConfiguration
, either by instantiating this class and changing the properties, or by subclassing.- Since:
- 9.3
- See Also:
Configuration.setConversionRules(ConversionRules)
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ConversionRules()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConversionRules
copy()
Converter
getConverter(AtomicType source, AtomicType target)
Get a Converter for a given pair of atomic types.NameChecker
getNameChecker()
Get the class that will be used to check whether XML names are valid.StringConverter
getStringConverter(AtomicType target)
Get a Converter that converts from strings to a given atomic type.StringToDouble
getStringToDoubleConverter()
Get the converter that will be used for converting strings to doubles and floats.boolean
isAllowYearZero()
Ask whether year zero is permitted in dates.boolean
isDeclaredNotation(java.lang.String uri, java.lang.String local)
Ask whether a given notation is accepted by xs:NOTATION and its subclasses.boolean
isValidURI(java.lang.CharSequence string)
Ask whether a string is a valid instance of xs:anyURI according to the rules defined by the current URICheckervoid
setAllowYearZero(boolean allowed)
Say whether year zero is permitted in dates.void
setNameChecker(NameChecker checker)
Set the class that will be used to check whether XML names are valid.void
setNotationSet(NotationSet notations)
Specify the set of notations that are accepted by xs:NOTATION and its subclasses.void
setStringToDoubleConverter(StringToDouble converter)
Set the converter that will be used for converting strings to doubles and floats.void
setURIChecker(URIChecker checker)
Set the class to be used for checking URI values.
-
-
-
Method Detail
-
copy
public ConversionRules copy()
-
setNameChecker
public void setNameChecker(NameChecker checker)
Set the class that will be used to check whether XML names are valid.- Parameters:
checker
- the class to be used for checking names. There are variants of this class depending on which version/edition of the XML specification is in use.
-
getNameChecker
public NameChecker getNameChecker()
Get the class that will be used to check whether XML names are valid.- Returns:
- the class to be used for checking names. There are variants of this class depending on which version/edition of the XML specification is in use.
-
setStringToDoubleConverter
public void setStringToDoubleConverter(StringToDouble converter)
Set the converter that will be used for converting strings to doubles and floats.- Parameters:
converter
- the converter to be used. There are two converters in regular use: they differ only in whether the lexical value "+INF" is recognized as a representation of positive infinity.
-
getStringToDoubleConverter
public StringToDouble getStringToDoubleConverter()
Get the converter that will be used for converting strings to doubles and floats.- Returns:
- the converter to be used. There are two converters in regular use: they differ only in whether the lexical value "+INF" is recognized as a representation of positive infinity.
-
setNotationSet
public void setNotationSet(NotationSet notations)
Specify the set of notations that are accepted by xs:NOTATION and its subclasses. This is to support the rule that for a notation to be valid, it must be declared in an xs:notation declaration in the schema- Parameters:
notations
- the set of notations that are recognized; or null, to indicate that all notation names are accepted
-
isDeclaredNotation
public boolean isDeclaredNotation(java.lang.String uri, java.lang.String local)
Ask whether a given notation is accepted by xs:NOTATION and its subclasses. This is to support the rule that for a notation to be valid, it must be declared in an xs:notation declaration in the schema- Parameters:
uri
- the namespace URI of the notationlocal
- the local part of the name of the notation- Returns:
- true if the notation is in the set of recognized notation names
-
setURIChecker
public void setURIChecker(URIChecker checker)
Set the class to be used for checking URI values. By default, no checking takes place.- Parameters:
checker
- an object to be used for checking URIs; or null if any string is accepted as an anyURI value
-
isValidURI
public boolean isValidURI(java.lang.CharSequence string)
Ask whether a string is a valid instance of xs:anyURI according to the rules defined by the current URIChecker- Parameters:
string
- the string to be checked against the rules for URIs- Returns:
- true if the string represents a valid xs:anyURI value
-
setAllowYearZero
public void setAllowYearZero(boolean allowed)
Say whether year zero is permitted in dates. By default it is not permitted when XSD 1.0 is in use, but it is permitted when XSD 1.1 is used.- Parameters:
allowed
- true if year zero is permitted
-
isAllowYearZero
public boolean isAllowYearZero()
Ask whether year zero is permitted in dates. By default it is not permitted when XSD 1.0 is in use, but it is permitted when XSD 1.1 is used.- Returns:
- true if year zero is permitted
-
getConverter
public Converter getConverter(AtomicType source, AtomicType target)
Get a Converter for a given pair of atomic types. These can be primitive types, derived types, or user-defined types. The converter implements the casting rules.- Parameters:
source
- the source typetarget
- the target type- Returns:
- a Converter if conversion between the two types is possible; or null otherwise
-
getStringConverter
public StringConverter getStringConverter(AtomicType target)
Get a Converter that converts from strings to a given atomic type. These can be primitive types, derived types, or user-defined types. The converter implements the casting rules.- Parameters:
target
- the target type- Returns:
- a Converter if conversion between the two types is possible; or null otherwise
-
-