public class NGCCRuntimeEx extends NGCCRuntime implements PatcherManager
| Modifier and Type | Class and Description |
|---|---|
private static class |
NGCCRuntimeEx.Context |
PatcherManager.Patcher| Modifier and Type | Field and Description |
|---|---|
boolean |
attributeFormDefault
The @attributeFormDefault value of the current schema.
|
int |
blockDefault
The @blockDefault value of the current schema.
|
boolean |
chameleonMode
True if the current schema is in a chameleon mode.
|
private NGCCRuntimeEx.Context |
currentContext |
SchemaImpl |
currentSchema
The schema currently being parsed.
|
SchemaDocumentImpl |
document
Points to the
SchemaDocumentImpl that represents the
schema document being parsed. |
private java.lang.String |
documentSystemId
URI that identifies the schema document.
|
boolean |
elementFormDefault
The @elementFormDefault value of the current schema.
|
private java.util.Stack<java.lang.String> |
elementNames
Keep the local name of elements encountered so far.
|
int |
finalDefault
The @finalDefault value of the current schema.
|
ParserContext |
parser
coordinator.
|
private NGCCRuntimeEx |
referer
Points to the schema document (the parser of it) that included/imported
this schema.
|
static java.lang.String |
XMLSchemaNSURI |
| Modifier | Constructor and Description |
|---|---|
(package private) |
NGCCRuntimeEx(ParserContext _parser) |
private |
NGCCRuntimeEx(ParserContext _parser,
boolean chameleonMode,
NGCCRuntimeEx referer) |
| Modifier and Type | Method and Description |
|---|---|
void |
addErrorChecker(Patch patcher) |
void |
addPatcher(Patch patcher) |
void |
checkDoubleDefError(XSDeclaration c) |
org.xml.sax.Locator |
copyLocator()
Creates a copy of the current locator object.
|
AnnotationParser |
createAnnotationParser()
Creates a new instance of annotation parser.
|
org.relaxng.datatype.ValidationContext |
createValidationContext()
Returns an immutable snapshot of the current context.
|
XmlString |
createXmlString(java.lang.String value) |
void |
endPrefixMapping(java.lang.String prefix) |
java.lang.String |
getAnnotationContextElementName()
Gets the element name that contains the annotation element.
|
org.xml.sax.ErrorHandler |
getErrorHandler() |
boolean |
hasAlreadyBeenRead()
Called when a new document is being parsed and checks
if the document has already been parsed before.
|
static boolean |
ignorableDuplicateComponent(XSDeclaration c) |
void |
importSchema(java.lang.String ns,
java.lang.String schemaLocation)
Imports the specified schema.
|
void |
includeSchema(java.lang.String schemaLocation)
Includes the specified schema.
|
void |
onEnterElementConsumed(java.lang.String uri,
java.lang.String localName,
java.lang.String qname,
org.xml.sax.Attributes atts)
Called by the generated handler code when an enter element
event is consumed.
|
void |
onLeaveElementConsumed(java.lang.String uri,
java.lang.String localName,
java.lang.String qname) |
boolean |
parseBoolean(java.lang.String v) |
void |
parseEntity(org.xml.sax.InputSource source,
boolean includeMode,
java.lang.String expectedNamespace,
org.xml.sax.Locator importLocation)
Parses the specified entity.
|
ForeignAttributesImpl |
parseForeignAttributes(ForeignAttributesImpl next) |
UName |
parseUName(java.lang.String qname)
Parses UName under the given context.
|
void |
reportError(java.lang.String msg) |
void |
reportError(java.lang.String msg,
org.xml.sax.Locator loc)
Reports an error during the parsing.
|
private org.xml.sax.InputSource |
resolveRelativeURL(java.lang.String namespaceURI,
java.lang.String relativeUri)
Resolves relative URI found in the document.
|
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri) |
protected void |
unexpectedX(java.lang.String token) |
characters, consumeAttribute, endDocument, endElement, getAttributeIndex, getCurrentAttributes, getLocator, ignorableWhitespace, processingInstruction, processList, redirectSubtree, replace, reset, resolveNamespacePrefix, sendEnterAttribute, sendEnterElement, sendLeaveAttribute, sendLeaveElement, sendText, setDocumentLocator, setRootHandler, skippedEntity, startDocument, startElement, trace, tracelnpublic final ParserContext parser
public SchemaImpl currentSchema
public int finalDefault
public int blockDefault
public boolean elementFormDefault
public boolean attributeFormDefault
public boolean chameleonMode
private java.lang.String documentSystemId
private final java.util.Stack<java.lang.String> elementNames
private final NGCCRuntimeEx referer
public SchemaDocumentImpl document
SchemaDocumentImpl that represents the
schema document being parsed.private NGCCRuntimeEx.Context currentContext
public static final java.lang.String XMLSchemaNSURI
NGCCRuntimeEx(ParserContext _parser)
private NGCCRuntimeEx(ParserContext _parser, boolean chameleonMode, NGCCRuntimeEx referer)
public void checkDoubleDefError(XSDeclaration c) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic static boolean ignorableDuplicateComponent(XSDeclaration c)
public void addPatcher(Patch patcher)
addPatcher in interface PatcherManagerpublic void addErrorChecker(Patch patcher)
addErrorChecker in interface PatcherManagerpublic void reportError(java.lang.String msg,
org.xml.sax.Locator loc)
throws org.xml.sax.SAXException
PatcherManagerreportError in interface PatcherManagerloc - location of the error in the source file, or null if
it's unavailable.org.xml.sax.SAXExceptionpublic void reportError(java.lang.String msg)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprivate org.xml.sax.InputSource resolveRelativeURL(java.lang.String namespaceURI,
java.lang.String relativeUri)
throws org.xml.sax.SAXException
namespaceURI - passed to the entity resolver.relativeUri - value of the schemaLocation attribute. Can be null.EntityResolver returned an InputSource,
or if the relativeUri parameter seems to be pointing to something.
Otherwise it returns null, in which case import/include should be abandoned.org.xml.sax.SAXExceptionpublic void includeSchema(java.lang.String schemaLocation)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic void importSchema(java.lang.String ns,
java.lang.String schemaLocation)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic boolean hasAlreadyBeenRead()
Used to avoid recursive inclusion. Note that the same document will be parsed multiple times if they are for different target namespaces.
The challenge we are facing here is that you have a graph of documents that reference each other. Each document has an unique URI to identify themselves, and references are done by using those. The graph may contain cycles.
Our goal here is to parse all the documents in the graph, without parsing the same document twice. This method implements this check.
One complication is the chameleon schema; a document can be parsed multiple times if they are under different target namespaces.
Also, note that when you resolve relative URIs in the @schemaLocation, their base URI is *NOT* the URI of the document.
public void parseEntity(org.xml.sax.InputSource source,
boolean includeMode,
java.lang.String expectedNamespace,
org.xml.sax.Locator importLocation)
throws org.xml.sax.SAXException
importLocation - The source location of the import/include statement.
Used for reporting errors.org.xml.sax.SAXExceptionpublic AnnotationParser createAnnotationParser()
public java.lang.String getAnnotationContextElementName()
public org.xml.sax.Locator copyLocator()
public org.xml.sax.ErrorHandler getErrorHandler()
public void onEnterElementConsumed(java.lang.String uri,
java.lang.String localName,
java.lang.String qname,
org.xml.sax.Attributes atts)
throws org.xml.sax.SAXException
NGCCRuntimePushes a new attribute set.
Note that attributes are NOT pushed at the startElement method, because the processing of the enterElement event can trigger other attribute events and etc.
This method will be called from one of handlers when it truely consumes the enterElement event.
onEnterElementConsumed in class NGCCRuntimeorg.xml.sax.SAXExceptionpublic void onLeaveElementConsumed(java.lang.String uri,
java.lang.String localName,
java.lang.String qname)
throws org.xml.sax.SAXException
onLeaveElementConsumed in class NGCCRuntimeorg.xml.sax.SAXExceptionpublic org.relaxng.datatype.ValidationContext createValidationContext()
public XmlString createXmlString(java.lang.String value)
public void startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
throws org.xml.sax.SAXException
startPrefixMapping in interface org.xml.sax.ContentHandlerstartPrefixMapping in class NGCCRuntimeorg.xml.sax.SAXExceptionpublic void endPrefixMapping(java.lang.String prefix)
throws org.xml.sax.SAXException
endPrefixMapping in interface org.xml.sax.ContentHandlerendPrefixMapping in class NGCCRuntimeorg.xml.sax.SAXExceptionpublic UName parseUName(java.lang.String qname) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic boolean parseBoolean(java.lang.String v)
protected void unexpectedX(java.lang.String token)
throws org.xml.sax.SAXException
unexpectedX in class NGCCRuntimeorg.xml.sax.SAXExceptionpublic ForeignAttributesImpl parseForeignAttributes(ForeignAttributesImpl next)