Class ValueConstraint


  • public class ValueConstraint
    extends java.lang.Object
    A value constraint represents the default or fixed value of an element declaration, attribute declaration, or attribute use
    • Constructor Detail

      • ValueConstraint

        public ValueConstraint​(ValueConstraint.Variety variety,
                               java.lang.String lexicalForm)
        Constructor; supplies the lexical form of the value as a string. The typed value will initially be set to the lexical form as an instance of UntypedAtomic.
    • Method Detail

      • getVariety

        public ValueConstraint.Variety getVariety()
        Get the variety of the constraint (fixed or default)
        Returns:
        the variety
      • getLexicalForm

        public java.lang.String getLexicalForm()
        Returns the lexical form of the value
        Returns:
        the fixed or default value defined by this component. The value returned is the value after whitespace normalization is applied to the value as written in the source schema.
      • getValue

        public AtomicSequence getValue()
        Gets the value as a typed value.
        Returns:
        the value. This will initially be saved as an UntypedAtomicValue; later, when the type is known, it will be converted to the correct type
      • getComparisonKey

        public java.lang.Comparable getComparisonKey()
        Get a comparison key that can be used for comparing values
        Returns:
        a comparison key
      • asFunction

        public Sequence asFunction()
        For use with the saxon:schema extension function, return the value constraint in the form of a function
        Returns:
        a function whose result gives details of the value constraint
      • testFixedValue

        public boolean testFixedValue​(Configuration config,
                                      java.lang.CharSequence value,
                                      SimpleType type,
                                      NamespaceResolver resolver)
                               throws ValidationException
        Test that the actual value of an element or attribute conforms to the required fixed value
        Parameters:
        config - the Saxon configuration
        value - the actual value
        type - the required type
        resolver - a namespace resolver, in case QNames are involved
        Returns:
        true if the value is OK, otherwise false
        Throws:
        ValidationException - if the value is not valid as an instance of the type