Package com.saxonica.ee.schema
Class Assertion
- java.lang.Object
-
- com.saxonica.ee.schema.SchemaStructure
-
- com.saxonica.ee.schema.Assertion
-
- All Implemented Interfaces:
SerializableSchemaComponent
,UserSchemaComponent
,javax.xml.transform.SourceLocator
,Location
,SchemaComponent
,org.xml.sax.Locator
public class Assertion extends SchemaStructure implements SchemaComponent, SerializableSchemaComponent
An Assertion schema component (See XML Schema 1.1 Part 1)
-
-
Constructor Summary
Constructors Constructor Description Assertion()
Assertion(EnterpriseConfiguration config, XPathExpression condition, XPathVariable valueVariable, java.util.Map<StructuredQName,XPathVariable> params, java.lang.String text)
Create an Assertion component
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
equals() is used when deciding whether two assertions are equal, as part of the type subsumption algorithm.FunctionItem
getComponentAsFunction()
Get the schema component in the form of a function item.XPathExpression
getCondition()
Get the XPath expression representing the assertion.java.lang.String
getConditionText()
Get the original text of the condition.java.lang.String
getMessage()
Get the user-defined error message associated with the assertionXPathStaticContext
getStaticContext()
Get the static context for the expressionSweep
getSweep()
Get the sweep of the expression; if motionless or consuming, the validator may attempt streamed evaluation.XPathVariable
getValueVariable()
Get the variable bound to the name $valueint
hashCode()
Hashcode is used when deciding whether two assertions are equal, as part of the type subsumption algorithm.void
serialize(SchemaModelSerializer serializer)
Serialize the schema componentstatic void
setDocumentsAndCollections(Configuration config, XPathDynamicContext context)
Set the dynamic XPath context to respond appropriately to requests for documents and collectionsvoid
setMessage(java.lang.String message)
Set the user-defined error message associated with the assertionvoid
setReturnsFailingNodes(boolean failingNodes)
Say that the expression should return the nodes that cause the expression to be invalid, rather than returning a true/false resultvoid
setStaticContext(XPathStaticContext staticContext)
Set the static context for the expression.void
setSweep(Sweep sweep)
Set the sweep of the expression; if motionless or consuming, the validator may attempt streamed evaluation.java.util.List<NodeInfo>
testComplex(NodeInfo contextItem, AtomicSequence value, ValidationContext rules)
Evaluate a complex type assertionboolean
testSimple(AtomicSequence value, ConversionRules rules)
Evaluate the assertion-
Methods inherited from class com.saxonica.ee.schema.SchemaStructure
elaborate, fixup, getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, lookForCycles, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setGeneratedId, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus, validate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getRedefinitionLevel, getValidationStatus
-
-
-
-
Constructor Detail
-
Assertion
public Assertion()
-
Assertion
public Assertion(EnterpriseConfiguration config, XPathExpression condition, XPathVariable valueVariable, java.util.Map<StructuredQName,XPathVariable> params, java.lang.String text)
Create an Assertion component- Parameters:
config
- the Saxon configurationcondition
- the compiled XPath expressionvalueVariable
- the variable to hold $value (may be null)params
- parameters declared using saxon:param and used in this expressiontext
- the original text of the XPath expression
-
-
Method Detail
-
getCondition
public XPathExpression getCondition()
Get the XPath expression representing the assertion. If xs:report is used, this will be the negation of the condition in the source schema.- Returns:
- the XPath expression
-
getValueVariable
public XPathVariable getValueVariable()
Get the variable bound to the name $value- Returns:
- the variable whose name is $value (may be null)
-
getConditionText
public java.lang.String getConditionText()
Get the original text of the condition.- Returns:
- the original text of the XPath expression
-
setMessage
public void setMessage(java.lang.String message)
Set the user-defined error message associated with the assertion- Parameters:
message
- the message defined using the saxon:message attribute, if present
-
getMessage
public java.lang.String getMessage()
Get the user-defined error message associated with the assertion- Returns:
- the user-defined error message, if any; otherwise null
-
setSweep
public void setSweep(Sweep sweep)
Set the sweep of the expression; if motionless or consuming, the validator may attempt streamed evaluation.- Parameters:
sweep
- the sweep of the expression (indicating whether it is capable of streamed evaluation)
-
getSweep
public Sweep getSweep()
Get the sweep of the expression; if motionless or consuming, the validator may attempt streamed evaluation.- Returns:
- the sweep of the expression (indicating whether it is capable of streamed evaluation)
-
setReturnsFailingNodes
public void setReturnsFailingNodes(boolean failingNodes)
Say that the expression should return the nodes that cause the expression to be invalid, rather than returning a true/false result- Parameters:
failingNodes
- set to true if the result is a set of nodes that cause the assertion to fail
-
setStaticContext
public void setStaticContext(XPathStaticContext staticContext)
Set the static context for the expression. Note: this is needed only to support exporting of the schema component model- Parameters:
staticContext
- the static context
-
getStaticContext
public XPathStaticContext getStaticContext()
Get the static context for the expression- Returns:
- the static context
-
testSimple
public boolean testSimple(AtomicSequence value, ConversionRules rules)
Evaluate the assertion- Parameters:
value
- the simple value to be tested, if any. If present, and if the expression uses $value, this value will be bound to the variable $value for evaluating the assertion.rules
- used to provide context information including the current error listener, URIResolver, and document pool, current date/time, etc. To take advantage of validation parameters (saxon:param) this must be a ValidationContext; but on other paths such as casting it is not possible to supply parameters, and the defaults are used- Returns:
- null if the assertion succeeds; otherwise a list of offending items which will be reported in any error message. Returning an empty list indicates that the assertion has failed but there are no specific offending items to be reported.
-
testComplex
public java.util.List<NodeInfo> testComplex(NodeInfo contextItem, AtomicSequence value, ValidationContext rules)
Evaluate a complex type assertion- Parameters:
contextItem
- the item to be used as the context item in evaluating the conditionvalue
- for a complex type with simple content, the typed value of the simple content, as a sequence of atomic values.rules
- used to provide context information including the current error listener, URIResolver, and document pool, current date/time, etc. To take advantage of validation parameters (saxon:param) this must be a ValidationContext; but on other paths such as casting it is not possible to supply parameters, and the defaults are used- Returns:
- an empty sequence if the assertion succeeds; otherwise a list of offending nodes which will be reported in any error message.
-
setDocumentsAndCollections
public static void setDocumentsAndCollections(Configuration config, XPathDynamicContext context)
Set the dynamic XPath context to respond appropriately to requests for documents and collections- Parameters:
config
- the Saxon configurationcontext
- the dynamic context for evaluation of XPath expressions, which will be modified by this request.
-
hashCode
public int hashCode()
Hashcode is used when deciding whether two assertions are equal, as part of the type subsumption algorithm. Assertions are equal if their XPath expressions are equal.- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
equals() is used when deciding whether two assertions are equal, as part of the type subsumption algorithm. Assertions are equal if their XPath expressions are equal.- Overrides:
equals
in classjava.lang.Object
-
serialize
public void serialize(SchemaModelSerializer serializer) throws XPathException
Serialize the schema component- Specified by:
serialize
in interfaceSerializableSchemaComponent
- Parameters:
serializer
- the object responsible for performing the serialization- Throws:
XPathException
- if serialization fails
-
getComponentAsFunction
public FunctionItem getComponentAsFunction()
Description copied from interface:SchemaComponent
Get the schema component in the form of a function item. This allows schema information to be made visible to XSLT or XQuery code. The function makes available the contents of the schema component as defined in the XSD specification. The function takes a string as argument representing a property name, and returns the corresponding property of the schema component. There is also a property "class" which returns the kind of schema component, for example "Attribute Declaration".- Specified by:
getComponentAsFunction
in interfaceSchemaComponent
- Overrides:
getComponentAsFunction
in classSchemaStructure
- Returns:
- the schema component represented as a function from property names to property values.
-
-