Class ValueConstraint

java.lang.Object
com.saxonica.ee.schema.ValueConstraint

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

    • ValueConstraint

      public ValueConstraint(ValueConstraint.Variety variety, UnicodeString 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. The lexical form may be null, in which case setValue(net.sf.saxon.om.AtomicSequence) must be called to supply the typed value
  • Method Details

    • getVariety

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

      public UnicodeString 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 of the constraint 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
    • matches

      public boolean matches(AtomicSequence supplied)
      Test whether a suplied value matches the constraint
    • 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, UnicodeString 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
    • serialize

      public void serialize(SchemaModelSerializer serializer) throws XPathException
      Serialize the value constraint
      Throws:
      XPathException