public abstract class GrammarReader extends org.xml.sax.helpers.XMLFilterImpl implements IDContextProvider2
Or you may want to use several pre-defined static "parse" methods for ease of use.GrammarReader reader = new RELAXGrammarReader(...); XMLReader parser = .... // create a new XMLReader here parser.setContentHandler(reader); parser.parse(whateverYouLike); return reader.grammar; // obtain parsed grammar.
Modifier and Type | Class and Description |
---|---|
static interface |
GrammarReader.BackPatch |
class |
GrammarReader.BackwardReferenceMap
memorizes what declarations are referenced from where.
|
class |
GrammarReader.ChainPrefixResolver |
static interface |
GrammarReader.PrefixResolver
namespace prefix to URI conversion map.
|
Modifier | Constructor and Description |
---|---|
protected |
GrammarReader(GrammarReaderController _controller,
SAXParserFactory parserFactory,
ExpressionPool pool,
State initialState)
constructor that should be called from parse method.
|
Modifier and Type | Method and Description |
---|---|
void |
_parse(Object source,
Locator errorSource)
parses a grammar from the specified source
|
void |
addBackPatchJob(GrammarReader.BackPatch job) |
void |
addBackPatchJob(XSDatatypeExp job) |
String |
combineURI(String baseURI,
String relativeURI)
converts the relative URL to the absolute one by using the specified base URL.
|
String |
combineURL(String baseURI,
String relativeURI)
Deprecated.
use the combineURI method.
|
abstract State |
createExpressionChildState(State parent,
StartTagInfo tag)
this method must be implemented by the derived class to create
language-default expresion state.
|
protected static SAXParserFactory |
createParserFactory()
Creates a default SAXParserFactory.
|
void |
detectUndefinedOnes(ReferenceContainer container,
String errMsg)
detects undefined ReferenceExp and reports it as an error.
|
void |
endPrefixMapping(String prefix) |
XSDatatype |
getBackwardCompatibleType(String typeName)
tries to obtain a DataType object by resolving obsolete names.
|
String |
getBaseUri() |
State |
getCurrentState()
gets current State object.
|
Locator |
getDeclaredLocationOf(Object o) |
Locator |
getLocator() |
abstract Grammar |
getResultAsGrammar()
gets the parsed AGM.
|
static Source |
inputSourceFromLSInput(LSInput input)
This is a stopgap until we can wean more of this code from SAX-dependence.
|
protected Expression |
interceptExpression(State state,
Expression exp)
intercepts an expression made by ExpressionState
before it is passed to the parent state.
|
protected abstract boolean |
isGrammarElement(StartTagInfo tag)
checks if given element is that of the grammar elements.
|
boolean |
isNotation(String notationName) |
boolean |
isUnparsedEntity(String entityName) |
Iterator |
iterateInscopeNamespaces()
Iterates Map.Entry objects which has the prefix as key and
the namespace URI as value.
|
protected abstract String |
localizeMessage(String propertyName,
Object[] args)
formats localized message with arguments
|
void |
onID(org.relaxng.datatype.Datatype dt,
StringToken token)
this method is called when a type with ID semantics is matched.
|
void |
parse(InputSource source)
parses a grammar from the specified source
|
void |
parse(Source source)
Parse from an arbitrary javax.xml.transform source.
|
void |
parse(String source)
parses a grammar from the specified source
|
void |
popState()
pops the previous state from the stack
|
void |
pushState(State newState,
State parentState,
StartTagInfo startTag)
pushs the current state into the stack and sets new one
|
void |
reportError(Exception nestedException,
String propertyName) |
void |
reportError(Exception nestedException,
String propertyName,
Object arg1) |
void |
reportError(Locator[] locs,
String propertyName,
Object[] args) |
void |
reportError(String propertyName) |
void |
reportError(String propertyName,
Object arg1) |
void |
reportError(String propertyName,
Object[] args,
Exception nestedException,
Locator[] errorLocations)
reports an error to the controller
|
void |
reportError(String propertyName,
Object arg1,
Object arg2) |
void |
reportError(String propertyName,
Object arg1,
Object arg2,
Object arg3) |
void |
reportWarning(String propertyName) |
void |
reportWarning(String propertyName,
Object arg1) |
void |
reportWarning(String propertyName,
Object[] args,
Locator[] locations)
reports a warning to the controller
|
void |
reportWarning(String propertyName,
Object arg1,
Object arg2) |
InputSource |
resolveLocation(State sourceState,
String uri)
obtains InputSource for the specified url.
|
String |
resolveNamespacePrefix(String prefix) |
void |
runBackPatchJob()
Performs all back-patchings.
|
void |
setDeclaredLocationOf(Object o) |
void |
setDocumentLocator(Locator loc) |
void |
setLocator(Locator locator) |
String[] |
splitQName(String qName)
Resolves a QName into a pair of (namespace URI,local name).
|
void |
startPrefixMapping(String prefix,
String uri) |
void |
switchSource(InputSource source,
State newState)
start reading input from a source defined by a SAX InputSource.
|
void |
switchSource(Source source,
State newState)
Start reading input from a source defined by a javax.xml.transform source.
|
void |
switchSource(State sourceState,
String url,
State newState)
Switchs InputSource to the specified URL and
parses it by the specified state.
|
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, warning
public final Controller controller
public final SAXParserFactory parserFactory
public final ExpressionPool pool
public static final GrammarReader.PrefixResolver basePrefixResolver
public GrammarReader.PrefixResolver prefixResolver
public final GrammarReader.BackwardReferenceMap backwardReference
public static final String ERR_MALPLACED_ELEMENT
public static final String ERR_CHARACTERS
public static final String ERR_DISALLOWED_ATTRIBUTE
public static final String ERR_MISSING_ATTRIBUTE
public static final String ERR_BAD_ATTRIBUTE_VALUE
public static final String ERR_MISSING_ATTRIBUTE_2
public static final String ERR_CONFLICTING_ATTRIBUTES
public static final String ERR_RECURSIVE_INCLUDE
public static final String ERR_FRAGMENT_IDENTIFIER
public static final String ERR_UNDEFINED_DATATYPE
public static final String ERR_DATATYPE_ALREADY_DEFINED
public static final String ERR_MISSING_CHILD_EXPRESSION
public static final String ERR_MORE_THAN_ONE_CHILD_EXPRESSION
public static final String ERR_MORE_THAN_ONE_CHILD_TYPE
public static final String ERR_MISSING_CHILD_TYPE
public static final String ERR_ILLEGAL_FINAL_VALUE
public static final String ERR_RUNAWAY_EXPRESSION
public static final String ERR_MISSING_TOPLEVEL
public static final String WRN_MAYBE_WRONG_NAMESPACE
public static final String WRN_DEPRECATED_TYPENAME
public static final String ERR_BAD_TYPE
public static final String ERR_RECURSIVE_DATATYPE
protected GrammarReader(GrammarReaderController _controller, SAXParserFactory parserFactory, ExpressionPool pool, State initialState)
protected static SAXParserFactory createParserFactory()
public abstract Grammar getResultAsGrammar()
protected abstract boolean isGrammarElement(StartTagInfo tag)
public void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping
in interface ContentHandler
startPrefixMapping
in class org.xml.sax.helpers.XMLFilterImpl
SAXException
public void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
endPrefixMapping
in class org.xml.sax.helpers.XMLFilterImpl
SAXException
public Iterator iterateInscopeNamespaces()
public String[] splitQName(String qName)
protected Expression interceptExpression(State state, Expression exp)
public XSDatatype getBackwardCompatibleType(String typeName)
public final InputSource resolveLocation(State sourceState, String uri) throws AbortException
sourceState
- The base URI of this state is used to resolve the resource.AbortException
public final String combineURI(String baseURI, String relativeURI)
public final String combineURL(String baseURI, String relativeURI)
public void switchSource(State sourceState, String url, State newState) throws AbortException
sourceState
- this state is used to resolve the URL.newState
- this state will parse top-level of new XML source.
this state receives document element by its createChildState method.AbortException
public void switchSource(InputSource source, State newState)
source
- newState
- public void switchSource(Source source, State newState)
source
- newState
- public final void parse(String source)
parse
in interface XMLReader
parse
in class org.xml.sax.helpers.XMLFilterImpl
public final void parse(InputSource source)
parse
in interface XMLReader
parse
in class org.xml.sax.helpers.XMLFilterImpl
public void parse(Source source) throws TransformerConfigurationException, TransformerException
SAXSource.sourceToInputSource(Source)
,
then this API will use that. Otherwise, it will use a transformer to
create a stream of SAX events. In that later case, the grammar controller
will not be called for any errors on the source side or to resolve
any references; the caller is responsible for making separate arrangements.source
- TransformerConfigurationException
TransformerException
public final void _parse(Object source, Locator errorSource)
public void setDeclaredLocationOf(Object o)
public void detectUndefinedOnes(ReferenceContainer container, String errMsg)
public void pushState(State newState, State parentState, StartTagInfo startTag)
public void popState()
public final State getCurrentState()
public abstract State createExpressionChildState(State parent, StartTagInfo tag)
public void setDocumentLocator(Locator loc)
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in class org.xml.sax.helpers.XMLFilterImpl
public String resolveNamespacePrefix(String prefix)
resolveNamespacePrefix
in interface org.relaxng.datatype.ValidationContext
public boolean isUnparsedEntity(String entityName)
isUnparsedEntity
in interface org.relaxng.datatype.ValidationContext
public boolean isNotation(String notationName)
isNotation
in interface org.relaxng.datatype.ValidationContext
public String getBaseUri()
getBaseUri
in interface org.relaxng.datatype.ValidationContext
public final void onID(org.relaxng.datatype.Datatype dt, StringToken token)
IDContextProvider2
onID
in interface IDContextProvider2
public final void addBackPatchJob(GrammarReader.BackPatch job)
public final void addBackPatchJob(XSDatatypeExp job)
public final void runBackPatchJob()
public final void reportError(String propertyName)
public final void reportError(String propertyName, Object arg1, Object arg2, Object arg3)
public final void reportError(Exception nestedException, String propertyName, Object arg1)
public final void reportWarning(String propertyName)
public final void reportError(String propertyName, Object[] args, Exception nestedException, Locator[] errorLocations)
public final void reportWarning(String propertyName, Object[] args, Locator[] locations)
public static Source inputSourceFromLSInput(LSInput input)
input
- protected abstract String localizeMessage(String propertyName, Object[] args)
public void setLocator(Locator locator)
public Locator getLocator()
Copyright © 2016 Oracle Corporation. All rights reserved.