public class TunedDTDParser extends TunableParserForXml<XMLDocumentIdentifier>
Modifier and Type | Class and Description |
---|---|
protected class |
TunedDTDParser.ParsingFailed
|
TunableParser.CharSet, TunableParser.ExtensionalCharSet
Modifier and Type | Field and Description |
---|---|
protected String |
currentElementName
Is !=null iff we are currently in an elements content definition.
|
protected CheckedMultimap_RD<String,String> |
entityUsage |
protected boolean |
errorOnExpand
Set by the corresponding parameter.
|
protected HashMap<String,DTD.Entity> |
generalEntities
Catalog of all general entities defined in this dtd model
|
protected MessageDisposer |
ignoreErrors |
static String |
LAZY_ENTITY_ERROR |
protected HashMap<String,DTD.CP> |
nicePE
Catalog of all those parameter entities which can be used
as content model.
|
protected HashMap<String,DTD.Entity> |
parameterEntities
Catalog of all parameter entities defined in this dtd model
|
static String |
UNPARSED_CONTENTS |
asciiLetterSet, decDigitSet, encNameSet, hexDigitSet, initialSet, nameSet, prefix_GE, prefix_PE, pubidCharSet, sNoPESet, sSet, stringconstant_IGNORE, stringconstant_INCLUDE, versionNumSet
base, in, messageGenerator, topleveldocumentid
Modifier | Constructor and Description |
---|---|
protected |
TunedDTDParser(Reader in,
@Opt XMLDocumentIdentifier id,
@Opt File base,
boolean errorOnExpand,
MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg)
Deprecated.
|
protected |
TunedDTDParser(Reader in,
@Opt XMLDocumentIdentifier id,
@Opt URL base,
boolean errorOnExpand,
MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg) |
Modifier and Type | Method and Description |
---|---|
protected DTD.AttDef |
attDef()
Parsing function.
|
protected DTD.Attlist |
attlistDecl()
Parsing function.
|
protected DTD.AttType |
attType()
Parsing function.
|
protected String |
attValue()
Parsing function.
|
protected static @Opt URL |
AUX_convert(@Opt File f)
Deprecated.
|
protected DTD.CP |
children()
Parsing function.
|
protected DTD.Comment |
comment()
Parsing function.
|
protected void |
conditionalSection(DTD.Dtd dtd)
Parsing function.
|
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.
|
protected DTD.ContentModel |
content()
Parsing function.
|
protected DTD.CP |
cp()
Parsing function.
|
void |
declareGeneralEntity(String name,
DTD.Entity entity) |
void |
declareParameterEntity(String name,
DTD.Entity entity)
Called by the parser, as soon as a parameter entity declaration
is recognized.
|
protected DTD.DefaultDecl |
defaultDecl()
Parsing function.
|
protected DTD.Dtd |
dtd()
Parsing function.
|
protected DTD.Element |
elementDecl()
Parsing function.
|
protected String |
encName()
Parsing function.
|
protected String |
encodingDecl()
Parsing function.
|
protected DTD.Entity |
entityDecl()
Parsing function.
|
protected String |
entityValue()
Parsing function.
|
protected DTD.Enumerated |
enumerated()
Parsing function.
|
protected void |
eq()
Parsing function for an equal sign with optional space before and after.
|
protected String |
eRef()
Parsing function.
|
protected XMLDocumentIdentifier |
externalId(boolean notation)
Parsing function.
|
protected void |
extSubset(DTD.Dtd dtd)
Toplevel parsing function, called by
dtd() and
conditionalSection(DTD.Dtd) . |
protected void |
fatalError(String msg)
Gnerates a
TunedDTDParser.ParsingFailed exception as a "semantic signal",
indicating that a sub-parser failed. |
protected void |
ignore()
Parsing function.
|
protected DTD.MarkupDecl |
markupDecl()
Parsing function.
|
protected DTD.Mixed |
mixed()
Parsing function.
|
protected DTD.CP |
modifierOpt(DTD.CP cp)
Parsing function.
|
protected String |
name()
Parsing function.
|
protected DTD.CP |
niceEntityValue()
Auxiliary parsing function to test whether a replacement text of an
entity is a well-formed content model.
|
protected String |
nmtoken()
Parsing function.
|
protected DTD.Notation |
notationDecl()
Parsing function.
|
static DTD.Dtd |
parse(Reader in,
XMLDocumentIdentifier id,
@Opt File base,
boolean errorOnExpand,
MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg)
Deprecated.
|
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.
|
static XMLDocumentIdentifier |
parseId(Reader in)
Parse an
XMLDocumentIdentifier . |
static DTD.Dtd |
parselocal(String in,
MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg)
Parse a local (or temporary generated) dtd declaration.
|
protected String |
peRef()
Parsing function.
|
protected DTD.PI |
pi()
Parsing function.
|
protected String |
pubidLiteral()
Parsing function.
|
void |
resolve(String name)
Insert the replace text of a parameter entity (internal or external)
into the input stream, framed by whitespace.
|
protected DTD.Entity |
retrieveGeneralEntity(String name)
Retrieve a general entity (internal or external) by its name,
Create error msg if undefined.
|
protected DTD.Entity |
retrieveParameterEntity(String name)
Retrieve a parameter entity (internal or external) by its name,
Create error msg if undefined.
|
protected String |
retrieveReplacementText(DTD.Entity entity)
Retrieve the replacement text of an entity (parameter or general,
internal or external).
|
protected void |
s()
Parsing function for required space, while expanding parameter entities.
|
protected void |
sNoPE()
Parsing function for required space, while NOT expanding parameter entities.
|
protected void |
sOpt()
Parsing function for optional space, while expanding parameter entities.
|
protected void |
sOptNoPE()
Parsing function for optional space, while NOT expanding parameter entities.
|
protected void |
storeEntityUsage(String def,
String refersTo) |
protected void |
sWsOpt()
Parsing function for space and PEs expanding to space.
|
protected String |
systemLiteral()
Parsing function.
|
protected DTD.TextDecl |
textDecl()
Parsing function.
|
protected String |
versionInfo()
Parsing function.
|
protected String |
versionNum()
Parsing function.
|
lookahead_pe, prefixedEntityName
consume, eof, error, failure, getMessageReceiver, lookahead_eof, lookahead, lookahead, lookahead, lookahead, lookahead, match, match, match, match, matchahead, matchahead, matchahead, matchUpto, matchUpto, readExternal, setBase, setMessageReceiver, skipUpto, warning, word
protected boolean errorOnExpand
protected HashMap<String,DTD.Entity> parameterEntities
protected HashMap<String,DTD.CP> nicePE
protected HashMap<String,DTD.Entity> generalEntities
protected final MessageDisposer ignoreErrors
protected String currentElementName
DTD.Dtd.entityUsage
.protected CheckedMultimap_RD<String,String> entityUsage
public static final String LAZY_ENTITY_ERROR
public static final String UNPARSED_CONTENTS
protected TunedDTDParser(Reader in, @Opt @Opt XMLDocumentIdentifier id, @Opt @Opt URL base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg)
@Deprecated protected TunedDTDParser(Reader in, @Opt @Opt XMLDocumentIdentifier id, @Opt @Opt File base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg)
TunedDTDParser(Reader,XMLDocumentIdentifier,URL,boolean,MessageReceiver)
instead.protected void fatalError(String msg)
TunedDTDParser.ParsingFailed
exception 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 by ignoreErrors
fatalError
in class TunableParser<XMLDocumentIdentifier>
public void declareGeneralEntity(String name, DTD.Entity entity)
public void declareParameterEntity(String name, DTD.Entity entity)
parameterEntities
.niceEntityValue()
and on success the result of this function
is (additionally) stored to nicePE
.protected DTD.Entity retrieveParameterEntity(String name)
name
- the name of the entity.protected DTD.Entity retrieveGeneralEntity(String name)
name
- the name of the entity.protected String retrieveReplacementText(DTD.Entity entity)
entity
- the entity for which the replacement text is retrievedpublic void resolve(String name)
cp()
for content models, and by s()
for
ubiquituous whitespace.name
- the name of the entity.public String constructReplacementText(String currentlyDefined, String definition, boolean normalizeSpace)
entityDecl()
for the whole text,
and for attValue()
, for explicitly extracted character references only.
FIXME whitespace coming out of entities/char references is NOT normalized.definition
- the text to expandpublic static DTD.Dtd parse(Reader in, XMLDocumentIdentifier id, URL base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg)
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@Deprecated public static DTD.Dtd parse(Reader in, XMLDocumentIdentifier id, @Opt @Opt File base, boolean errorOnExpand, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg)
parse(Reader,XMLDocumentIdentifier,URL,boolean,MessageReceiver)
instead.public static DTD.Dtd parselocal(String in, MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg)
in
- sourcemsg
- error channelpublic static XMLDocumentIdentifier parseId(Reader in)
XMLDocumentIdentifier
.
(Currently only called from TypedDomGenerator).in
- sourceprotected DTD.Dtd dtd()
protected DTD.TextDecl textDecl()
protected String versionInfo()
protected final void eq()
protected String versionNum()
protected String encodingDecl()
protected String encName()
protected void s()
protected void sOpt()
protected void sWsOpt()
>
or a conditional section ]
,
cf. XML standard "VC: Proper Conditional Section/PE Nesting"
"VC: Proper Declaration/PE Nesting" and
"VC: Proper Group/PE Nesting"protected void sNoPE()
protected void sOptNoPE()
protected void extSubset(DTD.Dtd dtd)
dtd()
and
conditionalSection(DTD.Dtd)
.protected void conditionalSection(DTD.Dtd dtd)
protected void ignore()
protected DTD.PI pi()
protected String name()
protected String nmtoken()
enumerated()
protected DTD.MarkupDecl markupDecl()
protected DTD.Comment comment()
protected DTD.Element elementDecl()
protected DTD.ContentModel content()
protected DTD.Mixed mixed()
protected DTD.CP children()
protected DTD.CP cp()
protected DTD.Entity entityDecl()
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-entAttention: if
errorOnExpand==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 combination
replacement==null && definition == LAZY_ENTITY_ERROR
The error message is sent LATER, iff (and when) the first attempt to
expand will happen.
There the combination will be changed to the combination
replacement== ""
, to prevent further
error generation.
definition 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)
protected XMLDocumentIdentifier externalId(boolean notation)
SYSTEM systemLiteral PUBLIC pubidLiteral systemLiteralThe production "NotationDecl" from the XML standard allows additionally (via the nonterminal "PublicId")
PUBLIC pubidLiteral
protected String systemLiteral()
protected String pubidLiteral()
protected String entityValue()
protected String eRef()
protected String peRef()
protected DTD.Notation notationDecl()
protected DTD.Attlist attlistDecl()
protected DTD.AttDef attDef()
protected DTD.AttType attType()
protected DTD.Enumerated enumerated()
protected DTD.DefaultDecl defaultDecl()
protected String attValue()
protected DTD.CP niceEntityValue()
cp()
, which will return a
DTD.CP
in case of success, or throw a TunedDTDParser.ParsingFailed
in case of error.
Only called from declareParameterEntity(String,DTD.Entity)
.see also the complete user documentation .