Class RELAXCoreReader

  • All Implemented Interfaces:
    IDContextProvider2, XSDatatypeResolver, org.relaxng.datatype.ValidationContext, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.XMLFilter, org.xml.sax.XMLReader
    Direct Known Subclasses:
    RELAXCoreIslandSchemaReader

    public class RELAXCoreReader
    extends RELAXReader
    implements XSDatatypeResolver
    reads RELAX module (classic RELAX module; no namespace extension) by SAX2 and constructs abstract grammar model. This class does not recognize extensions introduced by RELAX Namespace (like anyOtherElement, or <ref label="..." namespace="..." />.
    • Field Detail

      • relaxCoreSchema4Schema

        protected static org.iso_relax.verifier.Schema relaxCoreSchema4Schema
        Schema for schema of RELAX Core. Unless overrided, this schema for schema will be used to parse a RELAX Core schema. To override, call the full constructor of this class and change the parameter.
      • module

        protected RELAXModule module
        RELAX module object being under construction. object is created when target namespace is identified.
      • combinedAttPools

        protected final ReferenceContainer combinedAttPools
        contains all expressions that are going to be combined. ReferenceExp is used to wrap an expression to provide location information. (attPool element with combine attribute).
      • userDefinedTypes

        private final java.util.Map userDefinedTypes
        User-defined datatypes (from type name to XSDatatypeExp object.
      • ERR_NAMESPACE_NOT_SUPPROTED

        public static final java.lang.String ERR_NAMESPACE_NOT_SUPPROTED
        See Also:
        Constant Field Values
      • ERR_INCONSISTENT_TARGET_NAMESPACE

        public static final java.lang.String ERR_INCONSISTENT_TARGET_NAMESPACE
        See Also:
        Constant Field Values
      • ERR_MISSING_TARGET_NAMESPACE

        public static final java.lang.String ERR_MISSING_TARGET_NAMESPACE
        See Also:
        Constant Field Values
      • ERR_MULTIPLE_TAG_DECLARATIONS

        public static final java.lang.String ERR_MULTIPLE_TAG_DECLARATIONS
        See Also:
        Constant Field Values
      • ERR_MORE_THAN_ONE_INLINE_TAG

        public static final java.lang.String ERR_MORE_THAN_ONE_INLINE_TAG
        See Also:
        Constant Field Values
      • ERR_MULTIPLE_ATTPOOL_DECLARATIONS

        public static final java.lang.String ERR_MULTIPLE_ATTPOOL_DECLARATIONS
        See Also:
        Constant Field Values
      • ERR_UNDEFINED_ELEMENTRULE

        public static final java.lang.String ERR_UNDEFINED_ELEMENTRULE
        See Also:
        Constant Field Values
      • ERR_UNDEFINED_HEDGERULE

        public static final java.lang.String ERR_UNDEFINED_HEDGERULE
        See Also:
        Constant Field Values
      • ERR_UNDEFINED_TAG

        public static final java.lang.String ERR_UNDEFINED_TAG
        See Also:
        Constant Field Values
      • ERR_UNDEFINED_ATTPOOL

        public static final java.lang.String ERR_UNDEFINED_ATTPOOL
        See Also:
        Constant Field Values
      • ERR_LABEL_COLLISION

        public static final java.lang.String ERR_LABEL_COLLISION
        See Also:
        Constant Field Values
      • ERR_ROLE_COLLISION

        public static final java.lang.String ERR_ROLE_COLLISION
        See Also:
        Constant Field Values
      • WRN_NO_EXPROTED_LABEL

        public static final java.lang.String WRN_NO_EXPROTED_LABEL
        See Also:
        Constant Field Values
      • ERR_EXPROTED_HEDGERULE_CONSTRAINT

        public static final java.lang.String ERR_EXPROTED_HEDGERULE_CONSTRAINT
        See Also:
        Constant Field Values
      • ERR_MULTIPLE_ATTRIBUTE_CONSTRAINT

        public static final java.lang.String ERR_MULTIPLE_ATTRIBUTE_CONSTRAINT
        See Also:
        Constant Field Values
      • WRN_ILLEGAL_RELAXCORE_VERSION

        public static final java.lang.String WRN_ILLEGAL_RELAXCORE_VERSION
        See Also:
        Constant Field Values
    • Constructor Detail

      • RELAXCoreReader

        public RELAXCoreReader​(GrammarReaderController controller,
                               javax.xml.parsers.SAXParserFactory parserFactory,
                               RELAXCoreReader.StateFactory stateFactory,
                               ExpressionPool pool,
                               java.lang.String expectedTargetNamespace)
        full constructor.
        Parameters:
        stateFactory - this object creates all parsing state object. Parsing behavior can be modified by changing this object.
        expectedTargetNamespace - expected value of 'targetNamespace' attribute. If this value is null, then the module must have 'targetNamepsace' attribute. If this value is non-null and module doesn't have targetNamespace attribute, then expectedTargetNamespace is used as the module's target namespace (chameleon effect). If expectedNamespace differs from the module's targetNamespace attribute, then an error will be issued.
    • Method Detail

      • getRELAXCoreSchema4Schema

        public static org.iso_relax.verifier.Schema getRELAXCoreSchema4Schema()
      • getResult

        public final RELAXModule getResult()
        obtains parsed grammar object only if parsing was successful.
      • getResultAsGrammar

        public final Grammar getResultAsGrammar()
        Description copied from class: GrammarReader
        gets the parsed AGM. Should any error happens, this method should returns null. derived classes should implement type-safe getGrammar method, along with this method.
        Specified by:
        getResultAsGrammar in class GrammarReader
      • addUserDefinedType

        public final void addUserDefinedType​(XSDatatypeExp exp)
      • resolveXSDatatype

        public XSDatatypeExp resolveXSDatatype​(java.lang.String typeName)
        gets DataType object from type name. If undefined type name is specified, this method is responsible to report an error, and recovers.
        Specified by:
        resolveXSDatatype in interface XSDatatypeResolver
        Parameters:
        typeName - The type of this value varies in the schema language. In XML Schema, for example, in which QNames are used to designate datatypes, this parameter will be QName. In RELAX Core, in which the same syntax is used but NCName is used to designate datatypes. So this parameter will be NCName.
        Returns:
        A non-null valid object. An error should be reported and recovered by the callee.
      • canHaveOccurs

        protected boolean canHaveOccurs​(ExpressionState state)
        returns true if the given state can have "occurs" attribute.
      • resolveElementRef

        protected Expression resolveElementRef​(java.lang.String namespace,
                                               java.lang.String label)
        Description copied from class: RELAXReader
        obtains an Expression specified by given (namespace,label) pair. this method is called to parse <ref label="..." /> element.
        Specified by:
        resolveElementRef in class RELAXReader
      • resolveHedgeRef

        protected Expression resolveHedgeRef​(java.lang.String namespace,
                                             java.lang.String label)
        Description copied from class: RELAXReader
        obtains an Expression specified by given (namespace,label) pair. this method is called to parse <hedgeRef label="..." /> element.
        Specified by:
        resolveHedgeRef in class RELAXReader
      • resolveAttPoolRef

        protected Expression resolveAttPoolRef​(java.lang.String namespace,
                                               java.lang.String role)
      • wrapUp

        protected void wrapUp()
      • detectDoubleAttributeConstraints

        private void detectDoubleAttributeConstraints​(RELAXModule module)
        detect two AttributeExps that share the same target name. See DblAttrConstraintChecker for details.
      • localizeMessage

        protected java.lang.String localizeMessage​(java.lang.String propertyName,
                                                   java.lang.Object[] args)
        Description copied from class: GrammarReader
        formats localized message with arguments
        Overrides:
        localizeMessage in class RELAXReader