com.sun.msv.reader.trex.ng
Class RELAXNGReader

java.lang.Object
  |
  +--org.xml.sax.helpers.XMLFilterImpl
        |
        +--com.sun.msv.reader.GrammarReader
              |
              +--com.sun.msv.reader.trex.TREXBaseReader
                    |
                    +--com.sun.msv.reader.trex.ng.RELAXNGReader
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, IDContextProvider, ValidationContext, XMLFilter, XMLReader

public class RELAXNGReader
extends TREXBaseReader

reads RELAX NG grammar from SAX2 and constructs abstract grammar model.

Author:
Kohsuke KAWAGUCHI

Inner Class Summary
static class RELAXNGReader.StateFactory
          creates various State object, which in turn parses grammar.
 
Inner classes inherited from class com.sun.msv.reader.trex.TREXBaseReader
TREXBaseReader.StateFactory
 
Inner classes inherited from class com.sun.msv.reader.GrammarReader
GrammarReader.BackPatch, GrammarReader.BackwardReferenceMap, GrammarReader.ChainPrefixResolver, GrammarReader.PrefixResolver
 
Field Summary
static String ERR_BAD_DATA_VALUE
           
static String ERR_BAD_FACET
           
static String ERR_INCONSISTENT_COMBINE
           
static String ERR_INCONSISTENT_KEY_TYPE
           
static String ERR_INVALID_PARAMETERS
           
static String ERR_MULTIPLE_EXCEPT
           
static String ERR_REDEFINING_UNDEFINED
           
static String ERR_UNDEFINED_DATATYPE_1
           
static String ERR_UNDEFINED_KEY
           
static String ERR_UNKNOWN_DATATYPE_VOCABULARY_1
           
static String RELAXNGNamespace
          Namespace URI of RELAX NG
 
Fields inherited from class com.sun.msv.reader.trex.TREXBaseReader
ERR_BAD_COMBINE, ERR_COMBINE_MISSING, ERR_DUPLICATE_DEFINITION, ERR_INTERLEAVED_STRING, ERR_MISSING_CHILD_NAMECLASS, ERR_MORE_THAN_ONE_NAMECLASS, ERR_NONEXISTENT_PARENT_GRAMMAR, ERR_REPEATED_STRING, ERR_SEQUENCED_STRING, ERR_UNDECLARED_PREFIX, ERR_UNDEFINED_PATTERN, ERR_UNKNOWN_DATATYPE_VOCABULARY, sfactory, WRN_COMBINE_IGNORED, WRN_OBSOLETED_XMLSCHEMA_NAMSPACE
 
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_ILLEGAL_FINAL_VALUE, ERR_IO_EXCEPTION, 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_SAX_EXCEPTION, ERR_UNDEFINED_DATATYPE, ERR_XMLPARSERFACTORY_EXCEPTION, hadError, locator, parserFactory, pool, prefixResolver, WRN_DEPRECATED_TYPENAME, WRN_MAYBE_WRONG_NAMESPACE
 
Constructor Summary
RELAXNGReader(GrammarReaderController controller, javax.xml.parsers.SAXParserFactory parserFactory)
          easy-to-use constructor.
RELAXNGReader(GrammarReaderController controller, javax.xml.parsers.SAXParserFactory parserFactory, RELAXNGReader.StateFactory stateFactory, ExpressionPool pool)
          full constructor
 
Method Summary
 State createExpressionChildState(State parent, StartTagInfo tag)
          this method must be implemented by the derived class to create language-default expresion state.
 void endDocument()
           
 void endElement(String a, String b, String c)
           
static TREXGrammar parse(InputSource grammar, javax.xml.parsers.SAXParserFactory factory, GrammarReaderController controller)
          loads RELAX NG pattern
static TREXGrammar parse(String grammarURL, javax.xml.parsers.SAXParserFactory factory, GrammarReaderController controller)
          loads RELAX NG pattern
 Datatype resolveDataType(String localName)
          obtains a named DataType object referenced by a local name.
 DatatypeLibrary resolveDataTypeLibrary(String uri)
          obtains the DataTypeLibrary that represents the specified namespace URI.
 String resolveNamespacePrefix(String prefix)
          Resolves a namespace prefix to the corresponding namespace URI.
 void startDocument()
           
 void startElement(String a, String b, String c, Attributes d)
           
 void wrapUp()
          performs final wrap-up.
 
Methods inherited from class com.sun.msv.reader.trex.TREXBaseReader
getResult, getResultAsGrammar, getTargetNamespace
 
Methods inherited from class com.sun.msv.reader.GrammarReader
addBackPatchJob, combineURL, detectUndefinedOnes, endPrefixMapping, getBackwardCompatibleType, getCurrentState, getDeclaredLocationOf, isNotation, isUnparsedEntity, onID, onIDREF, parse, parse, popState, pushState, reportError, reportError, reportError, reportError, reportError, reportError, reportError, reportError, reportWarning, reportWarning, reportWarning, resolveLocation, setDeclaredLocationOf, setDocumentLocator, splitQName, startPrefixMapping, switchSource
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
characters, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RELAXNGNamespace

public static final String RELAXNGNamespace
Namespace URI of RELAX NG

ERR_BAD_FACET

public static final String ERR_BAD_FACET

ERR_INVALID_PARAMETERS

public static final String ERR_INVALID_PARAMETERS

ERR_BAD_DATA_VALUE

public static final String ERR_BAD_DATA_VALUE

ERR_UNDEFINED_KEY

public static final String ERR_UNDEFINED_KEY

ERR_UNDEFINED_DATATYPE_1

public static final String ERR_UNDEFINED_DATATYPE_1

ERR_INCONSISTENT_KEY_TYPE

public static final String ERR_INCONSISTENT_KEY_TYPE

ERR_INCONSISTENT_COMBINE

public static final String ERR_INCONSISTENT_COMBINE

ERR_REDEFINING_UNDEFINED

public static final String ERR_REDEFINING_UNDEFINED

ERR_UNKNOWN_DATATYPE_VOCABULARY_1

public static final String ERR_UNKNOWN_DATATYPE_VOCABULARY_1

ERR_MULTIPLE_EXCEPT

public static final String ERR_MULTIPLE_EXCEPT
Constructor Detail

RELAXNGReader

public RELAXNGReader(GrammarReaderController controller,
                     javax.xml.parsers.SAXParserFactory parserFactory)
easy-to-use constructor.

RELAXNGReader

public RELAXNGReader(GrammarReaderController controller,
                     javax.xml.parsers.SAXParserFactory parserFactory,
                     RELAXNGReader.StateFactory stateFactory,
                     ExpressionPool pool)
full constructor
Method Detail

parse

public static TREXGrammar parse(String grammarURL,
                                javax.xml.parsers.SAXParserFactory factory,
                                GrammarReaderController controller)
loads RELAX NG pattern

parse

public static TREXGrammar parse(InputSource grammar,
                                javax.xml.parsers.SAXParserFactory factory,
                                GrammarReaderController controller)
loads RELAX NG pattern

createExpressionChildState

public State createExpressionChildState(State parent,
                                        StartTagInfo tag)
Description copied from class: GrammarReader
this method must be implemented by the derived class to create language-default expresion state.
Overrides:
createExpressionChildState in class TREXBaseReader
Following copied from class: com.sun.msv.reader.GrammarReader
Returns:
null if the start tag is an error.

resolveDataType

public Datatype resolveDataType(String localName)
obtains a named DataType object referenced by a local name.
Overrides:
resolveDataType in class GrammarReader
Following copied from class: com.sun.msv.reader.GrammarReader
Parameters:
typeName - For RELAX, this is unqualified type name. For TREX, this is a QName.

resolveDataTypeLibrary

public DatatypeLibrary resolveDataTypeLibrary(String uri)
obtains the DataTypeLibrary that represents the specified namespace URI. If the specified URI is undefined, then this method issues an error to the user and returns null.

wrapUp

public void wrapUp()
Description copied from class: TREXBaseReader
performs final wrap-up. This method is called from the RootState object, after the parsing is completed.
Overrides:
wrapUp in class TREXBaseReader

resolveNamespacePrefix

public String resolveNamespacePrefix(String prefix)
Description copied from interface: ValidationContext
Resolves a namespace prefix to the corresponding namespace URI. This method is used for validating QName, for example.

If the prefix is "" (empty string), it indicates unprefixed value. The callee should resolved it as if it sees an unprefixed element, rather than unprefixed attribute.

If the prefix is "xml", then the callee must resolve this prefix into "http://www.w3.org/XML/1998/namespace", as defined in the XML Namespace rec.

Overrides:
resolveNamespacePrefix in class GrammarReader
Following copied from interface: org.relaxng.datatype.ValidationContext
Returns:
namespace URI of this prefix. If the specified prefix is not declared, the implementation must return null.

startDocument

public void startDocument()
                   throws SAXException
Overrides:
startDocument in class XMLFilterImpl

endDocument

public void endDocument()
                 throws SAXException
Overrides:
endDocument in class XMLFilterImpl

startElement

public void startElement(String a,
                         String b,
                         String c,
                         Attributes d)
                  throws SAXException
Overrides:
startElement in class TREXBaseReader

endElement

public void endElement(String a,
                       String b,
                       String c)
                throws SAXException
Overrides:
endElement in class TREXBaseReader