Class ContentValidator

    • Field Detail

      • nilled

        protected boolean nilled
      • pendingMessages

        protected java.util.List<java.lang.String> pendingMessages
    • Constructor Detail

      • ContentValidator

        public ContentValidator​(Receiver next)
    • Method Detail

      • setContainingElement

        public void setContainingElement​(StructuredQName name,
                                         Location locationId)
        Set the name of the containing element (for diagnostics)
        Parameters:
        name - identifies the name of the containing element
        locationId - identifies the location of the containing element
      • setElementDeclaration

        protected void setElementDeclaration​(ElementDecl decl)
        Set the element declaration that this validator is validating against
        Parameters:
        decl - the element declaration
      • getElementDeclaration

        protected ElementDecl getElementDeclaration()
        Get the element declaration that this validator is validating against
        Returns:
        the element declaration
      • getContainingElement

        public StructuredQName getContainingElement()
        Get the name of the element being validated (for diagnostics).
        Returns:
        the element name, or null if not available.
      • getContainingElementLocationId

        public Location getContainingElementLocationId()
        Get the location of the element being validated
        Returns:
        the location, or 0 if not available
      • getContainingElementName

        protected java.lang.String getContainingElementName()
        Get the containing element name, for use in error messages.
        Returns:
        the name of the containing element (plus surrounding punctuation), or the string "element" if not available
      • getSchemaType

        public abstract SchemaType getSchemaType()
        Get the schema type against which we are validating, if any
        Returns:
        the schema type that this validator is validating against, or null
      • setAnnotation

        protected final void setAnnotation​(SchemaType annotation)
        Set the type annotation code to be allocated by this validator
        Parameters:
        annotation - the integer fingerprint of the name of the type
      • getAnnotation

        protected final SchemaType getAnnotation()
        Get the type annotation code to be used on elements validated by this validator
        Returns:
        the integer fingerprint of the name of the type
      • getNamespaceResolver

        public NamespaceResolver getNamespaceResolver()
        Get the namespace resolver
        Returns:
        the namespace resolver
      • setNilled

        public void setNilled​(boolean nilled)
        Tell this validator whether xsi:nil="true" was specified on the element being validated
        Parameters:
        nilled - true if xsi:nil="true" was specified on the element being validated
      • isNilled

        public boolean isNilled()
        Determine whether xsi:nil = true was set on this element
        Returns:
        true if xsi:nil="true" was set
      • startElement

        public void startElement​(NodeName elemName,
                                 SchemaType type,
                                 AttributeMap attributes,
                                 NamespaceMap namespaces,
                                 Location location,
                                 int properties)
                          throws XPathException
        Handle the start tag for a child element of the element being validated
        Specified by:
        startElement in interface Receiver
        Overrides:
        startElement in class ProxyReceiver
        Parameters:
        elemName - the name of the element.
        type - the type annotation of the element.
        attributes - the attributes of this element
        namespaces - the in-scope namespaces of this element: generally this is all the in-scope namespaces, without relying on inheriting namespaces from parent elements
        location - an object providing information about the module, line, and column where the node originated
        properties - bit-significant properties of the element node. If there are no relevant properties, zero is supplied. The definitions of the bits are in class ReceiverOption
        Throws:
        XPathException - if an error occurs
      • makeValidator

        public static ContentValidator makeValidator​(ElementDecl decl,
                                                     StructuredQName elementName,
                                                     Location locationId,
                                                     ValidationContext validationContext,
                                                     SchemaType governingType,
                                                     int validation,
                                                     PipelineConfiguration pipe,
                                                     Receiver nextReceiver,
                                                     java.util.List<ValidationFailure> failures)
                                              throws MissingComponentException
        Factory method to make a validator for a particular element
        Parameters:
        decl - the element declaration to validate against. May be null.
        elementName - the name of the element (used only for diagnostics)
        locationId - the location of the element, or of the stylesheet instruction that generated this element (or zero)
        validationContext - information about the validation episode
        governingType - the type identified by xsi:type, if specified; otherwise null
        validation - the validation mode (strict, lax, preserve, strip)
        pipe - the pipeline configuration
        nextReceiver - the next receiver in the pipeline
        failures - a list which the method will populate with ValidationFailure objects in the event that a validity error is detected. (This is used to avoid throwing exceptions in the case where validation failures are a normal event)
        Returns:
        a Validator suitable for validating the content of this element
        Throws:
        MissingComponentException
      • getChildValidator

        protected abstract ContentValidator getChildValidator()
        Get a validator to handle the children of the current element. This is called immediately on return from the startElement call that starts this element.
        Returns:
        the validator to be used to handle the children
      • makeValidatorForType

        public static ContentValidator makeValidatorForType​(ElementDecl elementDecl,
                                                            SchemaType schemaType,
                                                            PipelineConfiguration pipe,
                                                            Receiver nextReceiver,
                                                            java.util.List<ValidationFailure> failures)
                                                     throws MissingComponentException
        Factory method to create a validator for elements of a given type
        Parameters:
        elementDecl - the element declaration if available, otherwise null (there will be no element declaration, for example, when doing lax validation against an xsi:type)
        schemaType - the simple or complex type against which the content of the element is to be validated
        pipe - the pipeline configuration
        nextReceiver - the next receiver in the pipeline
        failures - a list which the method will populate with any validity errors discovered by the method
        Returns:
        a Validator that can sit in the event pipeline to perform local validation of elements declared to have this type, or null if any validity errors were found
        Throws:
        MissingComponentException - if validation requires components that are missing from the schema. Note that unresolved references are errors only if the component is actually used, so they are detected during validation.
      • makeChildValidator

        protected void makeChildValidator​(ElementDecl decl,
                                          StructuredQName elementName,
                                          Location locationId,
                                          int process)
                                   throws XPathException
        Make a validator for the children of the element whose start tag is currently being processed. This will always set some kind of validator for the children in the field childValidator, even if the method fails
        Parameters:
        decl - the element declaration for this element, if applicable
        elementName - the name of this element, used for diagnostics
        locationId - location information, used for diagnostics
        Throws:
        XPathException - if a validation error occurs and if recovery from validation errors has not been requested. The error will always have been reported.
      • checkNoChildrenWhenNil

        protected void checkNoChildrenWhenNil​(Location location)
                                       throws XPathException
        A child element was encountered; check that this does not conflict with an xsi:nil=true attribute
        Parameters:
        location - the location to be used in any error report
        Throws:
        XPathException - if processing should terminate, for example because of too many errors
      • checkNoCharactersWhenNil

        protected void checkNoCharactersWhenNil​(Location location)
                                         throws XPathException
        Character content was encountered; check that this does not conflict with an xsi:nil=true attribute
        Parameters:
        location - the location to be used in any error report
        Throws:
        XPathException - if processing should terminate, for example because of too many errors