Class RestrictionChecker


  • public class RestrictionChecker
    extends java.lang.Object
    Checks RELAX NG contextual restrictions defined in the section 7.

    ExpressionWalker is used to walk the content model thoroughly. Depending on the current context, different walkers are used so that we can detect contextual restrictions properly.

    For each ElementExp and AttributeExp, its name class is checked to detect the constraint set out in the section 7.1.6. Also, a set is used to avoid redundant checks.

    • Field Detail

      • reader

        private final RELAXNGReader reader
        Reader object to which errors are reported.
      • errorContext

        private Expression errorContext
        The source location of this expression should be also reported in case of error.
      • visitedExps

        private final java.util.Set visitedExps
        Visited ElementExp/AttributeExps.
      • inExcept

        private final ExpressionWalker inExcept
        Used to visit children of the 'except' clause of data.
      • inGroupInOneOrMoreInElement

        private final ExpressionWalker inGroupInOneOrMoreInElement
        Used to visit children of group/interleave in oneOrMore in elements.
      • inOneOrMoreInElement

        private final ExpressionWalker inOneOrMoreInElement
        Used to visit children of oneOrMore in elements.
      • inElement

        private final ExpressionWalker inElement
        Used to visit children of elements.
      • inAttribute

        private final ExpressionWalker inAttribute
        Used to visit children of attributes.
      • inInterleaveInList

        private final ExpressionWalker inInterleaveInList
        Used to visit children of interleaves in lists.
      • inList

        private final ExpressionWalker inList
        Used to visit children of lists.
      • inStart

        private final ExpressionWalker inStart
        Used to visit the start pattern.
      • inAnyNameClass

        private final NameClassVisitor inAnyNameClass
        Used to visit children of AnyNameClass
      • inNsNameClass

        private final NameClassVisitor inNsNameClass
        Used to visit children of NamespaceNameClass
      • ERR_ATTRIBUTE_IN_EXCEPT

        private static final java.lang.String ERR_ATTRIBUTE_IN_EXCEPT
        See Also:
        Constant Field Values
      • ERR_ELEMENT_IN_EXCEPT

        private static final java.lang.String ERR_ELEMENT_IN_EXCEPT
        See Also:
        Constant Field Values
      • ERR_LIST_IN_EXCEPT

        private static final java.lang.String ERR_LIST_IN_EXCEPT
        See Also:
        Constant Field Values
      • ERR_TEXT_IN_EXCEPT

        private static final java.lang.String ERR_TEXT_IN_EXCEPT
        See Also:
        Constant Field Values
      • ERR_EMPTY_IN_EXCEPT

        private static final java.lang.String ERR_EMPTY_IN_EXCEPT
        See Also:
        Constant Field Values
      • ERR_SEQUENCE_IN_EXCEPT

        private static final java.lang.String ERR_SEQUENCE_IN_EXCEPT
        See Also:
        Constant Field Values
      • ERR_INTERLEAVE_IN_EXCEPT

        private static final java.lang.String ERR_INTERLEAVE_IN_EXCEPT
        See Also:
        Constant Field Values
      • ERR_ONEORMORE_IN_EXCEPT

        private static final java.lang.String ERR_ONEORMORE_IN_EXCEPT
        See Also:
        Constant Field Values
      • ERR_REPEATED_GROUPED_ATTRIBUTE

        private static final java.lang.String ERR_REPEATED_GROUPED_ATTRIBUTE
        See Also:
        Constant Field Values
      • ERR_ELEMENT_IN_ATTRIBUTE

        private static final java.lang.String ERR_ELEMENT_IN_ATTRIBUTE
        See Also:
        Constant Field Values
      • ERR_ATTRIBUTE_IN_ATTRIBUTE

        private static final java.lang.String ERR_ATTRIBUTE_IN_ATTRIBUTE
        See Also:
        Constant Field Values
      • ERR_ATTRIBUTE_IN_LIST

        private static final java.lang.String ERR_ATTRIBUTE_IN_LIST
        See Also:
        Constant Field Values
      • ERR_ELEMENT_IN_LIST

        private static final java.lang.String ERR_ELEMENT_IN_LIST
        See Also:
        Constant Field Values
      • ERR_LIST_IN_LIST

        private static final java.lang.String ERR_LIST_IN_LIST
        See Also:
        Constant Field Values
      • ERR_TEXT_IN_LIST

        private static final java.lang.String ERR_TEXT_IN_LIST
        See Also:
        Constant Field Values
      • ERR_ATTRIBUTE_IN_START

        private static final java.lang.String ERR_ATTRIBUTE_IN_START
        See Also:
        Constant Field Values
      • ERR_LIST_IN_START

        private static final java.lang.String ERR_LIST_IN_START
        See Also:
        Constant Field Values
      • ERR_TEXT_IN_START

        private static final java.lang.String ERR_TEXT_IN_START
        See Also:
        Constant Field Values
      • ERR_EMPTY_IN_START

        private static final java.lang.String ERR_EMPTY_IN_START
        See Also:
        Constant Field Values
      • ERR_SEQUENCE_IN_START

        private static final java.lang.String ERR_SEQUENCE_IN_START
        See Also:
        Constant Field Values
      • ERR_INTERLEAVE_IN_START

        private static final java.lang.String ERR_INTERLEAVE_IN_START
        See Also:
        Constant Field Values
      • ERR_DATA_IN_START

        private static final java.lang.String ERR_DATA_IN_START
        See Also:
        Constant Field Values
      • ERR_ONEORMORE_IN_START

        private static final java.lang.String ERR_ONEORMORE_IN_START
        See Also:
        Constant Field Values
      • ERR_DATA_IN_INTERLEAVE_IN_LIST

        private static final java.lang.String ERR_DATA_IN_INTERLEAVE_IN_LIST
        See Also:
        Constant Field Values
      • ERR_VALUE_IN_INTERLEAVE_IN_LIST

        private static final java.lang.String ERR_VALUE_IN_INTERLEAVE_IN_LIST
        See Also:
        Constant Field Values
      • ERR_ANYNAME_IN_ANYNAME

        private static final java.lang.String ERR_ANYNAME_IN_ANYNAME
        See Also:
        Constant Field Values
      • ERR_ANYNAME_IN_NSNAME

        private static final java.lang.String ERR_ANYNAME_IN_NSNAME
        See Also:
        Constant Field Values
      • ERR_NSNAME_IN_NSNAME

        private static final java.lang.String ERR_NSNAME_IN_NSNAME
        See Also:
        Constant Field Values
      • ERR_DUPLICATE_ATTRIBUTES

        private static final java.lang.String ERR_DUPLICATE_ATTRIBUTES
        See Also:
        Constant Field Values
      • ERR_DUPLICATE_ELEMENTS

        private static final java.lang.String ERR_DUPLICATE_ELEMENTS
        See Also:
        Constant Field Values
    • Constructor Detail

      • RestrictionChecker

        public RestrictionChecker​(RELAXNGReader _reader)
    • Method Detail

      • check

        public void check()
        Traverses the grammar and performs the contextual check.
      • reportError

        private void reportError​(Expression exp,
                                 java.lang.String errorMsg)
      • reportError

        private void reportError​(Expression exp,
                                 java.lang.String errorMsg,
                                 java.lang.Object[] args)
      • checkNameClass

        public void checkNameClass​(NameClass nc)
        Checks the contextual restriction on a name class.

        If an error is found, it is reported through GrammarReader.