Package com.saxonica.ee.schema
Class ValueConstraint
- java.lang.Object
-
- com.saxonica.ee.schema.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ValueConstraint.Variety
-
Constructor Summary
Constructors Constructor Description ValueConstraint(ValueConstraint.Variety variety, UnicodeString lexicalForm)
Constructor; supplies the lexical form of the value as a string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Sequence
asFunction()
For use with the saxon:schema extension function, return the value constraint in the form of a functionUnicodeString
getLexicalForm()
Returns the lexical form of the valueAtomicSequence
getValue()
Gets the value of the constraint as a typed value.ValueConstraint.Variety
getVariety()
Get the variety of the constraint (fixed or default)boolean
matches(AtomicSequence supplied)
Test whether a suplied value matches the constraintvoid
serialize(SchemaModelSerializer serializer)
Serialize the value constraintboolean
testFixedValue(Configuration config, UnicodeString value, SimpleType type, NamespaceResolver resolver)
Test that the actual value of an element or attribute conforms to the required fixed value
-
-
-
Constructor Detail
-
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 casesetValue(net.sf.saxon.om.AtomicSequence)
must be called to supply the typed value
-
-
Method Detail
-
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 configurationvalue
- the actual valuetype
- the required typeresolver
- 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
-
-