Class ConversionRules

java.lang.Object
net.sf.saxon.lib.ConversionRules
All Implemented Interfaces:
Serializable

public class ConversionRules extends Object implements 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 the Configuration, either by instantiating this class and changing the properties, or by subclassing.

Since:
9.3
See Also:
  • Constructor Details

    • ConversionRules

      public ConversionRules()
  • Method Details

    • 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(String uri, 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 notation
      local - 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(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 type
      target - 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