Top Description Inners Fields Constructors Methods
com.sun.msv.reader.relax.core

public Class RELAXCoreReader

extends RELAXReader
implements XSDatatypeResolver
Class Inheritance
All Implemented Interfaces
com.sun.msv.reader.datatype.xsd.XSDatatypeResolver
Known Direct Subclasses
com.sun.msv.relaxns.reader.relax.RELAXCoreIslandSchemaReader
Annotations
@SuppressWarnings:serial
Imports
java.util.Iterator, .Map, javax.xml.parsers.SAXParserFactory, org.iso_relax.verifier.Schema, org.relaxng.datatype.DatatypeException, org.xml.sax.InputSource, .Locator, com.sun.msv.datatype.xsd.DatatypeFactory, .XSDatatype, com.sun.msv.grammar.Expression, .ExpressionPool, .Grammar, .ReferenceContainer, .ReferenceExp, com.sun.msv.grammar.relax.AttPoolClause, .EmptyStringType, .Exportable, .HedgeRules, .NoneType, .RELAXModule, .TagClause, com.sun.msv.reader.ExpressionState, .GrammarReaderController, .RunAwayExpressionChecker, .State, com.sun.msv.reader.datatype.xsd.XSDVocabulary, .XSDatatypeExp, .XSDatatypeResolver, com.sun.msv.reader.relax.RELAXReader, com.sun.msv.reader.relax.core.checker.DblAttrConstraintChecker, .ExportedHedgeRuleChecker, .IdAbuseChecker, com.sun.msv.util.StartTagInfo

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="..." />.
Author
Kohsuke KAWAGUCHI

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
protected final ReferenceContainer
combinedAttPools

contains all expressions that are going to be combined.

public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
protected RELAXModule
module

RELAX module object being under construction.

protected static Schema
relaxCoreSchema4Schema

Schema for schema of RELAX Core.

private final Map<String, XSDatatypeExp>
userDefinedTypes

User-defined datatypes (from type name to XSDatatypeExp object.

public static final String
public static final String
Inherited from com.sun.msv.reader.relax.RELAXReader:
ERR_ILLEGAL_OCCURSERR_MISPLACED_OCCURSRELAXCoreNamespacesfactory

Constructor Summary

AccessConstructor and Description
public
public
RELAXCoreReader(GrammarReaderController controller, SAXParserFactory parserFactory, RELAXCoreReader.StateFactory
this object creates all parsing state object. Parsing behavior can be modified by changing this object.
stateFactory
,
ExpressionPool pool, String
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.
expectedTargetNamespace
)

full constructor.

Method Summary

Modifier and TypeMethod and Description
public final void
protected boolean
canHaveOccurs(ExpressionState state)

returns true if the given state can have "occurs" attribute.

private Expression
public State
createExpressionChildState(State parent, StartTagInfo tag)

Overrides com.sun.msv.reader.relax.RELAXReader.createExpressionChildState.

this method must be implemented by the derived class to create language-default expresion state.
private void
private void
detectDoubleAttributeConstraints(RELAXModule module)

detect two AttributeExps that share the same target name.

public static Schema
public final RELAXModule
getResult()

obtains parsed grammar object only if parsing was successful.

public final Grammar
protected final RELAXCoreReader.StateFactory
protected boolean
isGrammarElement(StartTagInfo tag)

Implements abstract com.sun.msv.reader.GrammarReader.isGrammarElement.

checks if given element is that of the grammar elements.
protected String
localizeMessage(String propertyName, Object[] args)

Overrides com.sun.msv.reader.relax.RELAXReader.localizeMessage.

formats localized message with arguments
public static RELAXModule
parse(String moduleURL, SAXParserFactory factory, GrammarReaderController controller, ExpressionPool pool)

loads RELAX module

public static RELAXModule
parse(InputSource module, SAXParserFactory factory, GrammarReaderController controller, ExpressionPool pool)

loads RELAX module

protected Expression
resolveAttPoolRef(String namespace, String role)

protected Expression
resolveElementRef(String namespace, String label)

Implements abstract com.sun.msv.reader.relax.RELAXReader.resolveElementRef.

obtains an Expression specified by given (namespace,label) pair.
protected Expression
resolveHedgeRef(String namespace, String label)

Implements abstract com.sun.msv.reader.relax.RELAXReader.resolveHedgeRef.

obtains an Expression specified by given (namespace,label) pair.
public XSDatatypeExp
resolveXSDatatype(String
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.
typeName
)

Implements com.sun.msv.reader.datatype.xsd.XSDatatypeResolver.resolveXSDatatype.

gets DataType object from type name.
protected void
Inherited from com.sun.msv.reader.relax.RELAXReader:
canHaveOccurscreateFacetStategetPoolinterceptExpression

Field Detail

combinedAttPoolsback to summary
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).

ERR_EXPROTED_HEDGERULE_CONSTRAINTback to summary
public static final String ERR_EXPROTED_HEDGERULE_CONSTRAINT
ERR_ID_ABUSEback to summary
public static final String ERR_ID_ABUSE
ERR_ID_ABUSE_1back to summary
public static final String ERR_ID_ABUSE_1
ERR_INCONSISTENT_TARGET_NAMESPACEback to summary
public static final String ERR_INCONSISTENT_TARGET_NAMESPACE
ERR_LABEL_COLLISIONback to summary
public static final String ERR_LABEL_COLLISION
ERR_MISSING_TARGET_NAMESPACEback to summary
public static final String ERR_MISSING_TARGET_NAMESPACE
ERR_MORE_THAN_ONE_INLINE_TAGback to summary
public static final String ERR_MORE_THAN_ONE_INLINE_TAG
ERR_MULTIPLE_ATTPOOL_DECLARATIONSback to summary
public static final String ERR_MULTIPLE_ATTPOOL_DECLARATIONS
ERR_MULTIPLE_ATTRIBUTE_CONSTRAINTback to summary
public static final String ERR_MULTIPLE_ATTRIBUTE_CONSTRAINT
ERR_MULTIPLE_TAG_DECLARATIONSback to summary
public static final String ERR_MULTIPLE_TAG_DECLARATIONS
ERR_NAMESPACE_NOT_SUPPROTEDback to summary
public static final String ERR_NAMESPACE_NOT_SUPPROTED
ERR_ROLE_COLLISIONback to summary
public static final String ERR_ROLE_COLLISION
ERR_UNDEFINED_ATTPOOLback to summary
public static final String ERR_UNDEFINED_ATTPOOL
ERR_UNDEFINED_ELEMENTRULEback to summary
public static final String ERR_UNDEFINED_ELEMENTRULE
ERR_UNDEFINED_HEDGERULEback to summary
public static final String ERR_UNDEFINED_HEDGERULE
ERR_UNDEFINED_TAGback to summary
public static final String ERR_UNDEFINED_TAG
moduleback to summary
protected RELAXModule module

RELAX module object being under construction. object is created when target namespace is identified.

relaxCoreSchema4Schemaback to summary
protected static 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.

userDefinedTypesback to summary
private final Map<String, XSDatatypeExp> userDefinedTypes

User-defined datatypes (from type name to XSDatatypeExp object.

WRN_ILLEGAL_RELAXCORE_VERSIONback to summary
public static final String WRN_ILLEGAL_RELAXCORE_VERSION
WRN_NO_EXPROTED_LABELback to summary
public static final String WRN_NO_EXPROTED_LABEL

Constructor Detail

RELAXCoreReaderback to summary
public RELAXCoreReader(GrammarReaderController controller, SAXParserFactory parserFactory, ExpressionPool pool)
RELAXCoreReaderback to summary
public RELAXCoreReader(GrammarReaderController controller, SAXParserFactory parserFactory, RELAXCoreReader.StateFactory stateFactory, ExpressionPool pool, String expectedTargetNamespace)

full constructor.

Parameters
stateFactory:RELAXCoreReader.StateFactory

this object creates all parsing state object. Parsing behavior can be modified by changing this object.

expectedTargetNamespace:String

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

addUserDefinedTypeback to summary
public final void addUserDefinedType(XSDatatypeExp exp)
canHaveOccursback to summary
protected boolean canHaveOccurs(ExpressionState state)

returns true if the given state can have "occurs" attribute.

choiceOfExportedback to summary
private Expression choiceOfExported(ReferenceContainer con)
createExpressionChildStateback to summary
public State createExpressionChildState(State parent, StartTagInfo tag)

Overrides com.sun.msv.reader.relax.RELAXReader.createExpressionChildState.

Doc from com.sun.msv.reader.GrammarReader.createExpressionChildState.

this method must be implemented by the derived class to create language-default expresion state.

Returns:State

null if the start tag is an error.

detectCollisionback to summary
private void detectCollision(ReferenceContainer col1, ReferenceContainer col2, String errMsg)
detectDoubleAttributeConstraintsback to summary
private void detectDoubleAttributeConstraints(RELAXModule module)

detect two AttributeExps that share the same target name. See DblAttrConstraintChecker for details.

getRELAXCoreSchema4Schemaback to summary
public static Schema getRELAXCoreSchema4Schema()
getResultback to summary
public final RELAXModule getResult()

obtains parsed grammar object only if parsing was successful.

getResultAsGrammarback to summary
public final Grammar getResultAsGrammar()

Implements abstract com.sun.msv.reader.GrammarReader.getResultAsGrammar.

Doc from com.sun.msv.reader.GrammarReader.getResultAsGrammar.

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.

getStateFactoryback to summary
protected final RELAXCoreReader.StateFactory getStateFactory()
isGrammarElementback to summary
protected boolean isGrammarElement(StartTagInfo tag)

Implements abstract com.sun.msv.reader.GrammarReader.isGrammarElement.

Doc from com.sun.msv.reader.GrammarReader.isGrammarElement.

checks if given element is that of the grammar elements.

localizeMessageback to summary
protected String localizeMessage(String propertyName, Object[] args)

Overrides com.sun.msv.reader.relax.RELAXReader.localizeMessage.

Doc from com.sun.msv.reader.GrammarReader.localizeMessage.

formats localized message with arguments

parseback to summary
public static RELAXModule parse(String moduleURL, SAXParserFactory factory, GrammarReaderController controller, ExpressionPool pool)

loads RELAX module

parseback to summary
public static RELAXModule parse(InputSource module, SAXParserFactory factory, GrammarReaderController controller, ExpressionPool pool)

loads RELAX module

resolveAttPoolRefback to summary
protected Expression resolveAttPoolRef(String namespace, String role)
resolveElementRefback to summary
protected Expression resolveElementRef(String namespace, String label)

Implements abstract com.sun.msv.reader.relax.RELAXReader.resolveElementRef.

Doc from com.sun.msv.reader.relax.RELAXReader.resolveElementRef.

obtains an Expression specified by given (namespace,label) pair. this method is called to parse <ref label="..." /> element.

resolveHedgeRefback to summary
protected Expression resolveHedgeRef(String namespace, String label)

Implements abstract com.sun.msv.reader.relax.RELAXReader.resolveHedgeRef.

Doc from com.sun.msv.reader.relax.RELAXReader.resolveHedgeRef.

obtains an Expression specified by given (namespace,label) pair. this method is called to parse <hedgeRef label="..." /> element.

resolveXSDatatypeback to summary
public XSDatatypeExp resolveXSDatatype(String typeName)

Implements com.sun.msv.reader.datatype.xsd.XSDatatypeResolver.resolveXSDatatype.

gets DataType object from type name. If undefined type name is specified, this method is responsible to report an error, and recovers.

Parameters
typeName:String

Doc from com.sun.msv.reader.datatype.xsd.XSDatatypeResolver.resolveXSDatatype.

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:XSDatatypeExp

Doc from com.sun.msv.reader.datatype.xsd.XSDatatypeResolver.resolveXSDatatype.

A non-null valid object. An error should be reported and recovered by the callee.

wrapUpback to summary
protected void wrapUp()
com.sun.msv.reader.relax.core back to summary

public Class RELAXCoreReader.StateFactory

extends StateFactory
Class Inheritance
Known Direct Subclasses
com.sun.msv.relaxns.reader.relax.RELAXCoreIslandSchemaReader.StateFactory

Field Summary

Modifier and TypeField and Description
protected XSDVocabulary

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected State
attPool(State parent, StartTagInfo tag)

protected State
protected State
protected State
element(State parent, StartTagInfo tag)

protected State
protected State
protected State
include(State parent, StartTagInfo tag)

protected State
protected State
mixed(State parent, StartTagInfo tag)

protected State
refRole(State parent, StartTagInfo tag)

protected State
protected State
tag(State parent, StartTagInfo tag)

protected State
Inherited from com.sun.msv.reader.relax.RELAXReader.StateFactory:
choiceemptyfacetshedgeRefnonerefLabelsequence

Field Detail

vocabularyback to summary
protected XSDVocabulary vocabulary

Constructor Detail

StateFactoryback to summary
public StateFactory()

Method Detail

attPoolback to summary
protected State attPool(State parent, StartTagInfo tag)
attributeback to summary
protected State attribute(State parent, StartTagInfo tag)
divInModuleback to summary
protected State divInModule(State parent, StartTagInfo tag)
elementback to summary
protected State element(State parent, StartTagInfo tag)
elementRuleback to summary
protected State elementRule(State parent, StartTagInfo tag)
hedgeRuleback to summary
protected State hedgeRule(State parent, StartTagInfo tag)
includeback to summary
protected State include(State parent, StartTagInfo tag)
interface_back to summary
protected State interface_(State parent, StartTagInfo tag)
mixedback to summary
protected State mixed(State parent, StartTagInfo tag)
refRoleback to summary
protected State refRole(State parent, StartTagInfo tag)
simpleTypeback to summary
protected State simpleType(State parent, StartTagInfo tag)
tagback to summary
protected State tag(State parent, StartTagInfo tag)
tagInlineback to summary
protected State tagInline(State parent, StartTagInfo tag)