Package com.sun.msv.reader.xmlschema
Class XMLSchemaReader
java.lang.Object
org.xml.sax.helpers.XMLFilterImpl
com.sun.msv.reader.GrammarReader
com.sun.msv.reader.xmlschema.XMLSchemaReader
- All Implemented Interfaces:
IDContextProvider2,XSDatatypeResolver,org.relaxng.datatype.ValidationContext,ContentHandler,DTDHandler,EntityResolver,ErrorHandler,XMLFilter,XMLReader
parses XML representation of XML Schema and constructs AGM.
- Author:
- Kohsuke KAWAGUCHI
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classcreates various State object, which in turn parses grammar.Nested classes/interfaces inherited from class com.sun.msv.reader.GrammarReader
GrammarReader.BackPatch, GrammarReader.BackwardReferenceMap, GrammarReader.ChainPrefixResolver, GrammarReader.PrefixResolver -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringvalue of the "attributeFormDefault" attribute.protected Stringvalue of the "blockDefault" attribute.protected StringThe intended target namespace of the chameleon schema.final ComplexTypeExpexpression that matches to "ur-type" when used as a complex type.protected XMLSchemaSchemabooleana flag that indicates State objects should check duplicate definitions.protected Stringvalue of the "elementFormDefault" attribute.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringvalue of the "finalDefault" attribute.protected final XMLSchemaGrammargrammar object which is being under construction.tables that store all SystemIds that we've read.static final Stringstatic final Stringstatic final Stringprotected static org.iso_relax.verifier.SchemaSchema for schema of W3C XML Schema.static final Stringnamespace URI of XML Schema declarations.static final Stringstatic final Stringprotected final XMLSchemaSchemaXMLSchemaSchema object that has XMLSchemaNamespace as its target namespace.final ReferenceExpcontent model that matches to optional xsi:schemaLocation or xsi:noNamespaceSchemaLocation.Fields inherited from class com.sun.msv.reader.GrammarReader
backwardReference, basePrefixResolver, controller, ERR_BAD_ATTRIBUTE_VALUE, ERR_BAD_TYPE, ERR_CHARACTERS, ERR_CONFLICTING_ATTRIBUTES, ERR_DATATYPE_ALREADY_DEFINED, ERR_DISALLOWED_ATTRIBUTE, ERR_FRAGMENT_IDENTIFIER, ERR_ILLEGAL_FINAL_VALUE, ERR_MALPLACED_ELEMENT, ERR_MISSING_ATTRIBUTE, ERR_MISSING_ATTRIBUTE_2, ERR_MISSING_CHILD_EXPRESSION, ERR_MISSING_CHILD_TYPE, ERR_MISSING_TOPLEVEL, ERR_MORE_THAN_ONE_CHILD_EXPRESSION, ERR_MORE_THAN_ONE_CHILD_TYPE, ERR_RECURSIVE_DATATYPE, ERR_RECURSIVE_INCLUDE, ERR_RUNAWAY_EXPRESSION, ERR_UNDEFINED_DATATYPE, parserFactory, pool, prefixResolver, WRN_DEPRECATED_TYPENAME, WRN_MAYBE_WRONG_NAMESPACE -
Constructor Summary
ConstructorsConstructorDescriptionXMLSchemaReader(GrammarReaderController controller) easy-to-use constructor.XMLSchemaReader(GrammarReaderController controller, SAXParserFactory parserFactory) XMLSchemaReader(GrammarReaderController controller, SAXParserFactory parserFactory, ExpressionPool pool) XMLSchemaReader(GrammarReaderController controller, SAXParserFactory parserFactory, XMLSchemaReader.StateFactory stateFactory, ExpressionPool pool) -
Method Summary
Modifier and TypeMethodDescriptioncreateAttributeState(State parent, StartTagInfo tag) creates a state object that parses "attribute","attributeGroup ref", and "anyAttribute".createExpressionChildState(State parent, StartTagInfo tag) this method must be implemented by the derived class to create language-default expresion state.createFacetState(State parent, StartTagInfo tag) createModelGroupState(State parent, StartTagInfo tag) creates a state object that parses "all"/"group ref"/"choice" and "sequence".getOrCreateSchema(String namespaceURI) gets a reference to XMLSchemaGrammar object whose target namespace is the specified one.final XMLSchemaGrammargets the parsed AGM.static org.iso_relax.verifier.Schemaprotected ExpressioninterceptExpression(State state, Expression exp) intercepts an expression made by ExpressionState before it is passed to the parent state.protected booleanchecks if given element is that of the grammar elements.final booleanisSchemaDefined(XMLSchemaSchema schema) booleanprotected StringlocalizeMessage(String propertyName, Object[] args) formats localized message with argumentsfinal voidmarkSchemaAsDefined(XMLSchemaSchema schema) static XMLSchemaGrammarparse(String grammarURL, SAXParserFactory factory, GrammarReaderController controller) loads XML Schemastatic XMLSchemaGrammarparse(Source schema, GrammarReaderController controller) Convenience method to create a reader and read a single scheme.static XMLSchemaGrammarparse(InputSource grammar, SAXParserFactory factory, GrammarReaderController controller) loads XML SchemaprocessOccurs(Expression item, int minOccurs, int maxOccurs) Adds maxOccurs/minOccurs semantics to a given expression.processOccurs(StartTagInfo startTag, Expression item) Adds maxOccurs/minOccurs semantics to a given expression.resolveBuiltinDataType(String typeLocalName) resolves built-in datatypes (URI: http://www.w3.org/2001/XMLSchema)resolveBuiltinSimpleType(String typeLocalName) Gets a built-in datatype as SimpleTypeExp.protected StringresolveNamespaceOfAttributeDecl(String formValue) protected StringresolveNamespaceOfElementDecl(String formValue) resolveQNameRef(StartTagInfo tag, String attName, XMLSchemaReader.RefResolver resolver) resolveXSDatatype(String typeQName) Resolves a simple type name into the corresponding XSDatatypeExp object.voidsetAdditionalNamespaceMap(Map<String, String> additionalNamespaceMap) String[]splitQName(String qName) Resolves a QName into a pair of (namespace URI,local name).protected voidswitchSource(State sourceState, State newRootState) protected voidwrapUp()performs final wrap-up of parsing.Methods inherited from class com.sun.msv.reader.GrammarReader
_parse, addBackPatchJob, addBackPatchJob, combineURI, combineURL, createParserFactory, detectUndefinedOnes, endPrefixMapping, getBackwardCompatibleType, getBaseUri, getCurrentState, getDeclaredLocationOf, getLocator, inputSourceFromLSInput, isNotation, isUnparsedEntity, iterateInscopeNamespaces, onID, parse, parse, parse, popState, pushState, reportError, reportError, reportError, reportError, reportError, reportError, reportError, reportError, reportWarning, reportWarning, reportWarning, reportWarning, resolveLocation, resolveNamespacePrefix, runBackPatchJob, setDeclaredLocationOf, setDocumentLocator, setLocator, startPrefixMapping, switchSource, switchSource, switchSourceMethods inherited from class org.xml.sax.helpers.XMLFilterImpl
characters, endDocument, endElement, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startElement, unparsedEntityDecl, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
xmlSchema4XmlSchema
protected static org.iso_relax.verifier.Schema xmlSchema4XmlSchemaSchema for schema of W3C XML Schema. -
xsiSchemaLocationExp
content model that matches to optional xsi:schemaLocation or xsi:noNamespaceSchemaLocation. -
XMLSchemaSchemaLocationAttributes
- See Also:
-
complexUrType
expression that matches to "ur-type" when used as a complex type. -
attributeFormDefault
value of the "attributeFormDefault" attribute. -
elementFormDefault
value of the "elementFormDefault" attribute. -
finalDefault
value of the "finalDefault" attribute. Set to null if the attribute was not specified. -
blockDefault
value of the "blockDefault" attribute. Set to null if the attribute was not specified. -
grammar
grammar object which is being under construction. -
currentSchema
-
xsdSchema
XMLSchemaSchema object that has XMLSchemaNamespace as its target namespace. -
parsedFiles
tables that store all SystemIds that we've read. map from target namespace URI to set of system ids. This field is used to prevent double inclusion. Strictly speaking, comparision based on system id is not enough. The spec calls for "the necessity of establishing identity component by component" (section 4.2.1, last note). -
sfactory
-
XMLSchemaNamespace
namespace URI of XML Schema declarations.- See Also:
-
XMLSchemaNamespace_old
- See Also:
-
chameleonTargetNamespace
The intended target namespace of the chameleon schema.When parsing a chameleon schema (inclusion of a schema without the targetNamespace attribute), this field is set to the target namespace of the callee, so that any reference occured in the chameleon schema is treated correctly.
This field must be set to null in other cases. In that case, QName resolution is handled just normally.
This field is maintained by
SchemaIncludedState. -
doDuplicateDefinitionCheck
public boolean doDuplicateDefinitionChecka flag that indicates State objects should check duplicate definitions. This flag is set to false when in <redefine>. Otherwise this flag is true. -
ERR_MAXOCCURS_IS_NECESSARY
- See Also:
-
ERR_UNIMPLEMENTED_FEATURE
- See Also:
-
ERR_UNDECLARED_PREFIX
- See Also:
-
ERR_INCONSISTENT_TARGETNAMESPACE
- See Also:
-
ERR_IMPORTING_SAME_NAMESPACE
- See Also:
-
ERR_DUPLICATE_SCHEMA_DEFINITION
- See Also:
-
ERR_UNDEFINED_ELEMENTTYPE
- See Also:
-
ERR_UNDEFINED_ATTRIBUTE_DECL
- See Also:
-
ERR_UNDEFINED_ATTRIBUTE_GROUP
- See Also:
-
ERR_UNDEFINED_COMPLEX_TYPE
- See Also:
-
ERR_UNDEFINED_SIMPLE_TYPE
- See Also:
-
ERR_UNDEFINED_COMPLEX_OR_SIMPLE_TYPE
- See Also:
-
ERR_UNDEFINED_ELEMENT_DECL
- See Also:
-
ERR_UNDEFINED_GROUP
- See Also:
-
ERR_UNDEFINED_SCHEMA
- See Also:
-
WRN_UNSUPPORTED_ANYELEMENT
- See Also:
-
WRN_OBSOLETED_NAMESPACE
- See Also:
-
ERR_UNDEFINED_OR_FORWARD_REFERENCED_TYPE
- See Also:
-
ERR_REDEFINE_UNDEFINED
- See Also:
-
ERR_DUPLICATE_ATTRIBUTE_DEFINITION
- See Also:
-
ERR_DUPLICATE_COMPLEXTYPE_DEFINITION
- See Also:
-
ERR_DUPLICATE_ATTRIBUTE_GROUP_DEFINITION
- See Also:
-
ERR_DUPLICATE_GROUP_DEFINITION
- See Also:
-
ERR_DUPLICATE_ELEMENT_DEFINITION
- See Also:
-
ERR_DUPLICATE_IDENTITY_CONSTRAINT_DEFINITION
- See Also:
-
ERR_BAD_XPATH
- See Also:
-
ERR_UNDEFINED_KEY
- See Also:
-
ERR_INVALID_BASETYPE_FOR_SIMPLECONTENT
- See Also:
-
ERR_KEY_FIELD_NUMBER_MISMATCH
- See Also:
-
ERR_KEYREF_REFERRING_NON_KEY
- See Also:
-
ERR_UNRELATED_TYPES_IN_SUBSTITUTIONGROUP
- See Also:
-
ERR_RECURSIVE_SUBSTITUTION_GROUP
- See Also:
-
ERR_FIXED_AND_DEFAULT
- See Also:
-
WRN_IMPLICIT_URTYPE_FOR_ELEMENT
- See Also:
-
-
Constructor Details
-
XMLSchemaReader
easy-to-use constructor. -
XMLSchemaReader
-
XMLSchemaReader
public XMLSchemaReader(GrammarReaderController controller, SAXParserFactory parserFactory, ExpressionPool pool) -
XMLSchemaReader
public XMLSchemaReader(GrammarReaderController controller, SAXParserFactory parserFactory, XMLSchemaReader.StateFactory stateFactory, ExpressionPool pool)
-
-
Method Details
-
parse
public static XMLSchemaGrammar parse(String grammarURL, SAXParserFactory factory, GrammarReaderController controller) loads XML Schema -
parse
public static XMLSchemaGrammar parse(InputSource grammar, SAXParserFactory factory, GrammarReaderController controller) loads XML Schema -
parse
public static XMLSchemaGrammar parse(Source schema, GrammarReaderController controller) throws TransformerConfigurationException, TransformerException Convenience method to create a reader and read a single scheme.- Parameters:
schema-controller-- Returns:
- Throws:
TransformerConfigurationExceptionTransformerException
-
getXmlSchemaForXmlSchema
public static org.iso_relax.verifier.Schema getXmlSchemaForXmlSchema() -
getResult
-
getResultAsGrammar
Description copied from class:GrammarReadergets 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:
getResultAsGrammarin classGrammarReader
-
getOrCreateSchema
gets a reference to XMLSchemaGrammar object whose target namespace is the specified one. If there is no such object, this method creates a new instance and returns it. -
createExpressionChildState
Description copied from class:GrammarReaderthis method must be implemented by the derived class to create language-default expresion state.- Specified by:
createExpressionChildStatein classGrammarReader- Returns:
- null if the start tag is an error.
-
createModelGroupState
creates a state object that parses "all"/"group ref"/"choice" and "sequence". -
createAttributeState
creates a state object that parses "attribute","attributeGroup ref", and "anyAttribute". -
createFacetState
-
isGrammarElement
Description copied from class:GrammarReaderchecks if given element is that of the grammar elements.- Specified by:
isGrammarElementin classGrammarReader
-
markSchemaAsDefined
-
isSchemaDefined
-
resolveNamespaceOfAttributeDecl
-
resolveNamespaceOfElementDecl
-
resolveBuiltinDataType
resolves built-in datatypes (URI: http://www.w3.org/2001/XMLSchema)- Returns:
- null if the type is not defined.
-
resolveBuiltinSimpleType
Gets a built-in datatype as SimpleTypeExp.- Returns:
- null if the type is not defined.
-
isSchemaNamespace
-
resolveXSDatatype
Resolves a simple type name into the corresponding XSDatatypeExp object.- Specified by:
resolveXSDatatypein interfaceXSDatatypeResolver- Parameters:
typeQName- 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.
-
resolveQNameRef
public Expression resolveQNameRef(StartTagInfo tag, String attName, XMLSchemaReader.RefResolver resolver) -
splitQName
Resolves a QName into a pair of (namespace URI,local name).When we are parsing a "chameleon schema", any reference to the default empty namespace("") has to be treated as a reference to the intended target namespace.
- Overrides:
splitQNamein classGrammarReader
-
interceptExpression
Description copied from class:GrammarReaderintercepts an expression made by ExpressionState before it is passed to the parent state. derived class can perform further wrap-up before it is received by the parent. This mechanism is used by RELAXReader to handle occurs attribute.- Overrides:
interceptExpressionin classGrammarReader
-
processOccurs
Adds maxOccurs/minOccurs semantics to a given expression. For example, if this method receives A, minOccurs=0, and maxOccurs=3, then this method should return something like (A,(A,A?)?)? -
processOccurs
Adds maxOccurs/minOccurs semantics to a given expression.- Parameters:
maxOccurs- -1 to represent "unbounded".
-
switchSource
- Throws:
AbortException
-
wrapUp
protected void wrapUp()performs final wrap-up of parsing. this method is called by RootState after the parsing of the entire documents has completed. -
localizeMessage
Description copied from class:GrammarReaderformats localized message with arguments- Specified by:
localizeMessagein classGrammarReader
-
getAdditionalNamespaceMap
-
setAdditionalNamespaceMap
-