Package eu.bandm.tools.dtd
Class TunedDTDParser
java.lang.Object
eu.bandm.tools.rdparser.TunableParser<XMLDocumentIdentifier>
eu.bandm.tools.rdparser.TunableParserForXml<XMLDocumentIdentifier>
eu.bandm.tools.dtd.TunedDTDParser
- Direct Known Subclasses:
EntityClassifier,HtmlRenderer
@CyclicDependency(reason="convenient invocation from class Dtd")
public class TunedDTDParser
extends TunableParserForXml<XMLDocumentIdentifier>
Parser implementation, optimized for treating the idiosyncratics
of the w3c xml dtd specification.
Cf. w3c xml spec
Cf. w3c xml spec
Attention : The base classes have the following convention w.r.t errors: they use "MessageGenerator", provide "error()", "warning()" etc., and require "fatalError()" to be provided here!
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classNested classes/interfaces inherited from class eu.bandm.tools.rdparser.TunableParser
TunableParser.CharSet, TunableParser.ExtensionalCharSet -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringIs !=null iff we are currently in an elements content definition.protected CheckedMultimap_RD<String, String> protected booleanSet by the corresponding parameter.protected HashMap<String, DTD.Entity> Catalog of all general entities defined in this dtd modelprotected static final MessageDisposerstatic final StringCatalog of all those parameter entities which can be used as content model.protected HashMap<String, DTD.Entity> Catalog of all parameter entities defined in this dtd modelstatic final TunedDTDParser.ParsingFailedstatic final StringFields inherited from class eu.bandm.tools.rdparser.TunableParserForXml
asciiLetterSet, decDigitSet, encNameSet, hexDigitSet, initialSet, nameSet, PREFIX_GE, PREFIX_PE, pubidCharSet, sNoPESet, sSet, STRINGCONSTANT_IGNORE, STRINGCONSTANT_INCLUDE, versionNumSetFields inherited from class eu.bandm.tools.rdparser.TunableParser
base, in, messageReceiver, startColumnNumber, startLineNumber, topleveldocumentid -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTunedDTDParser(Reader in, @Opt XMLDocumentIdentifier id, @Opt File base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) Deprecated, for removal: This API element is subject to removal in a future version.protectedTunedDTDParser(Reader in, @Opt XMLDocumentIdentifier id, @Opt URL base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) -
Method Summary
Modifier and TypeMethodDescriptionprotected DTD.AttDefattDef()Parsing function.protected DTD.AttlistParsing function.protected DTD.AttTypeattType()Parsing function.protected StringattValue()Parsing function.AUX_convert(@Opt File f) Deprecated, for removal: This API element is subject to removal in a future version.protected DTD.CPchildren()Parsing function.protected DTD.Commentcomment()Parsing function.protected voidParsing function.constructReplacementText(String currentlyDefined, String definition, boolean normalizeSpace) Normalizes whitespace and expands pe-refs and character refs in the literal definition value of an INTERNAL (parameter or general) entity.protected DTD.ContentModelcontent()Parsing function.protected DTD.CPcp()Parsing function.voiddeclareGeneralEntity(String name, DTD.Entity entity) voiddeclareParameterEntity(String name, DTD.Entity entity) Called by the parser, as soon as a parameter entity declaration is recognized.protected DTD.DefaultDeclParsing function.protected DTD.Dtddtd()Parsing function.protected DTD.ElementParsing function.protected StringencName()Parsing function.protected StringParsing function.protected DTD.EntityParsing function.protected StringParsing function.protected DTD.EnumeratedParsing function.protected final voideq()Parsing function for an equal sign with optional space before and after.protected StringeRef()Parsing function.protected XMLDocumentIdentifierexternalId(boolean notation) Parsing function.protected voidToplevel parsing function, called bydtd()andconditionalSection(DTD.Dtd).protected voidfatalError(String msg) Gnerates aTunedDTDParser.ParsingFailedexception as a "semantic signal", indicating that a sub-parser failed.protected voidignore()Parsing function.protected DTD.MarkupDeclParsing function.protected DTD.Mixedmixed()Parsing function.protected DTD.CPmodifierOpt(DTD.CP cp) Parsing function.protected Stringname()Parsing function.protected DTD.CPAuxiliary parsing function to test whether a replacement text of an entity is a well-formed content model.protected Stringnmtoken()Parsing function.protected DTD.NotationParsing function.static DTD.Dtdparse(Reader in, XMLDocumentIdentifier id, @Opt File base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) Deprecated, for removal: This API element is subject to removal in a future version.static DTD.Dtdparse(Reader in, XMLDocumentIdentifier id, URL base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) Main service access point for parsing a dtd into an internal model.static XMLDocumentIdentifierParse anXMLDocumentIdentifier.static DTD.Dtdparselocal(String in, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) Parse a local (or temporary generated) dtd declaration.protected StringpeRef()Parsing function.protected DTD.PIpi()Parsing function.protected StringParsing function.voidInsert the replace text of a parameter entity (internal or external) into the input stream, framed by whitespace.protected DTD.EntityretrieveGeneralEntity(String name) Retrieve a general entity (internal or external) by its name, Create error msg if undefined.protected DTD.EntityRetrieve a parameter entity (internal or external) by its name, Create error msg if undefined.protected StringretrieveReplacementText(DTD.Entity entity) Retrieve the replacement text of an entity (parameter or general, internal or external).protected voids()Parsing function for required space, while expanding parameter entities.protected voidsNoPE()Parsing function for required space, while NOT expanding parameter entities.protected voidsOpt()Parsing function for optional space, while expanding parameter entities.protected voidsOptNoPE()Parsing function for optional space, while NOT expanding parameter entities.protected voidstoreEntityUsage(String def, String refersTo) protected voidsWsOpt()Parsing function for space and PEs expanding to space.protected StringParsing function.protected StringParsing function.protected StringParsing function.protected DTD.XmlDeclxmlDecl()Parsing function.Methods inherited from class eu.bandm.tools.rdparser.TunableParserForXml
lookaheadPe, prefixedEntityNameMethods inherited from class eu.bandm.tools.rdparser.TunableParser
consume, eof, error, failure, getMessageReceiver, lookahead, lookahead, lookahead, lookahead, lookahead, lookaheadEOF, match, match, match, match, matchahead, matchahead, matchahead, matchUpto, matchUpto, readExternal, setBase, setMessageReceiver, skipUpto, warning, word
-
Field Details
-
errorOnExpand
protected boolean errorOnExpandSet by the corresponding parameter. Iff true, an unreachable (/non-existing) external parsed (parameter/general) entity does generate an error message not before it is really used/expanded (which may never happen!) -
parameterEntities
Catalog of all parameter entities defined in this dtd model -
nicePE
Catalog of all those parameter entities which can be used as content model. -
generalEntities
Catalog of all general entities defined in this dtd model -
ignoreErrors
-
parsingFailed
-
currentElementName
Is !=null iff we are currently in an elements content definition. The use of PEs will be recorded inDTD.Dtd.entityUsage. -
entityUsage
-
LAZY_ENTITY_ERROR
- See Also:
-
UNPARSED_CONTENTS
- See Also:
-
-
Constructor Details
-
TunedDTDParser
protected TunedDTDParser(Reader in, @Opt @Opt XMLDocumentIdentifier id, @Opt @Opt URL base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) -
TunedDTDParser
@Deprecated(forRemoval=true) protected TunedDTDParser(Reader in, @Opt @Opt XMLDocumentIdentifier id, @Opt @Opt File base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
AUX_convert
Deprecated, for removal: This API element is subject to removal in a future version.Aux method to cnvert a fileinto an URL via URI ??? -
fatalError
Gnerates aTunedDTDParser.ParsingFailedexception as a "semantic signal", indicating that a sub-parser failed. It is called ONLY by "match()", which is only called if the match is syntactically necessary. This exception is caught by the "speculating" parsing of entity contents. During this parsing the error receiver is inactivated (replaced byignoreErrors- Specified by:
fatalErrorin classTunableParser<XMLDocumentIdentifier>
-
declareGeneralEntity
-
declareParameterEntity
Called by the parser, as soon as a parameter entity declaration is recognized.
First it is stored toparameterEntities.
Then a "speculative parsing" is started with the start symbolniceEntityValue()and on success the result of this function is (additionally) stored tonicePE. -
retrieveParameterEntity
Retrieve a parameter entity (internal or external) by its name, Create error msg if undefined.- Parameters:
name- the name of the entity.
-
retrieveGeneralEntity
Retrieve a general entity (internal or external) by its name, Create error msg if undefined.- Parameters:
name- the name of the entity.
-
retrieveReplacementText
Retrieve the replacement text of an entity (parameter or general, internal or external). Create error msg in case of "errorOnExpand" mode when an external entity could not be read when it was declared.- Parameters:
entity- the entity for which the replacement text is retrieved
-
resolve
Insert the replace text of a parameter entity (internal or external) into the input stream, framed by whitespace. Is only called bycp()for content models, and bys()for ubiquituous whitespace.- Parameters:
name- the name of the entity.
-
constructReplacementText
public String constructReplacementText(String currentlyDefined, String definition, boolean normalizeSpace) Normalizes whitespace and expands pe-refs and character refs in the literal definition value of an INTERNAL (parameter or general) entity. Called byentityDecl()for the whole text, and forattValue(), for explicitly extracted character references only. FIXME whitespace coming out of entities/char references is NOT normalized.- Parameters:
definition- the text to expand
-
parse
public static DTD.Dtd parse(Reader in, XMLDocumentIdentifier id, URL base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) Main service access point for parsing a dtd into an internal model.- Parameters:
in- the source of the dtd to parseid- the document id, for tracing etc.base- from where relative includes shall be resolvederrorOnExpand- whether any "read error" of external parsed entities is signalled not before they are expanded (which may never happen!)msg- receiver for errors and warnings
-
parse
@Deprecated(forRemoval=true) public static DTD.Dtd parse(Reader in, XMLDocumentIdentifier id, @Opt @Opt File base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) Deprecated, for removal: This API element is subject to removal in a future version. -
parselocal
public static DTD.Dtd parselocal(String in, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) Parse a local (or temporary generated) dtd declaration. (Currently only called by TypedDomGenerator and /bajama/mmod/core/MMod2Dtd.java)- Parameters:
in- sourcemsg- error channel- Returns:
- null if parsing is not possible = error has occured
-
parseId
Parse anXMLDocumentIdentifier. (Currently only called from TypedDomGenerator).- Parameters:
in- source- Returns:
- null if parsing is not possible
-
dtd
Parsing function. -
xmlDecl
Parsing function. -
versionInfo
Parsing function. -
eq
protected final void eq()Parsing function for an equal sign with optional space before and after. -
versionNum
Parsing function. -
encodingDecl
Parsing function. -
encName
Parsing function. -
storeEntityUsage
-
s
protected void s()Parsing function for required space, while expanding parameter entities. -
sOpt
protected void sOpt()Parsing function for optional space, while expanding parameter entities. -
sWsOpt
protected void sWsOpt()Parsing function for space and PEs expanding to space. Used for optional space immediately preceding a closing parenthesis of a declaration>or a conditional section], cf. XML standard "VC: Proper Conditional Section/PE Nesting" "VC: Proper Declaration/PE Nesting" and "VC: Proper Group/PE Nesting" -
sNoPE
protected void sNoPE()Parsing function for required space, while NOT expanding parameter entities. -
sOptNoPE
protected void sOptNoPE()Parsing function for optional space, while NOT expanding parameter entities. -
extSubset
Toplevel parsing function, called bydtd()andconditionalSection(DTD.Dtd). -
conditionalSection
Parsing function. -
ignore
protected void ignore()Parsing function. Does not look for any PERef. This is possible because of "VC: Proper Conditional Section/PE Nesting" -
pi
Parsing function. -
name
Parsing function. Accepts a non-empty name according to production "Name" from XML-specs. -
nmtoken
Parsing function. Only called fromenumerated() -
markupDecl
Parsing function. -
comment
Parsing function. -
elementDecl
Parsing function. -
content
Parsing function. -
mixed
Parsing function. -
children
Parsing function. Assume OPENING parenthesis just consumed. Leaves closing parenthesis un-consumed. -
cp
Parsing function. -
modifierOpt
Parsing function. -
entityDecl
Parsing function. Entities are encoded with the following combinations:parameter id(=fileposition) notation --------------------------------------------------------------------- true null (null) internal PE true !=null (null) external PE false null (null) internal general entity false !=null ==null external parsed gen-ent false !=null !=null external UNparsed gen-ent
Attention: iferrorOnExpand==true, then a non-existing (non-loadable) external (parsed/unparsed) entitiy does NOT raise an error here, when being declared. Instead, this fact is encoded by the combinationreplacement==null && definition == LAZY_ENTITY_ERRORThe error message is sent LATER, iff (and when) the first attempt to expand will happen. There the combination will be changed to the combinationreplacement== "", to prevent further error generation.
In all non-error cases, the values of the fields definition and replacement aredefinition replacement --------------------------------------------------------------------- internal PE verbatim source text processed/expanded source text (expand char refs and PE refs) external PE read file contents ==definition (no expansion) internal gen.Ent. verbatim source text processed/expanded source text (expand char refs and PE refs) external gen.Ent. read file contents ==definition (no expansion) unparsed (general external) entity dedicated string constant (used as flag) -
externalId
Parsing function. Normal XML document identifier (via the nonterminal "ExternalId") take the formSYSTEM systemLiteral PUBLIC pubidLiteral systemLiteralThe production "NotationDecl" from the XML standard allows additionally (via the nonterminal "PublicId")PUBLIC pubidLiteral
-
systemLiteral
Parsing function. -
pubidLiteral
Parsing function. -
entityValue
Parsing function. Returns the verbatim text input, w/o any expansion. -
eRef
Parsing function. Consumes lead in character and semicolon, but delivers only characters in between. FIXME word(hexDigitSet) includes EMPTY WORD !?!?! -
peRef
Parsing function. Consumes lead in character and semicolon, but delivers only characters in between. -
notationDecl
Parsing function. -
attlistDecl
Parsing function. -
attDef
Parsing function. DOES consume trailing sOpt(). Differs from XML specs: They start with obligate S ! This obligate s not reflected in this parser here ?!?!? FIXME -
attType
Parsing function. Does NOT consume trailing sOpt(). -
enumerated
Parsing function. -
defaultDecl
Parsing function. Does NOT consume trailing space. -
attValue
Parsing function. -
niceEntityValue
Auxiliary parsing function to test whether a replacement text of an entity is a well-formed content model. A "test run" of the parser must be set-up before this method is called in a try/catch block, and the main parser reconstructed afterwards. It calls the parser functioncp(), which will return aDTD.CPin case of success, or throw aTunedDTDParser.ParsingFailedin case of error. Only called fromdeclareParameterEntity(String,DTD.Entity).
-
TunedDTDParser(Reader,XMLDocumentIdentifier,URL,boolean,MessageReceiver)instead.