There are 2 main modes for DTDReader, depending on whether it is parsing internal or external subset. Parsing of internal subset is somewhat simpler, since no dependency checking is needed. For external subset, handling of parameter entities is bit more complicated, as care has to be taken to distinguish between using PEs defined in int. subset, and ones defined in ext. subset itself. This determines cachability of external subsets.
Reader also implements simple stand-alone functionality for flattening DTD files (expanding all references to their eventual textual form); this is sometimes useful when optimizing modularized DTDs (which are more maintainable) into single monolithic DTDs (which in general can be more performant).
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final Boolean | |
| pack-priv static final Boolean | |
| pack-priv static final boolean | INTERN_SHARED_NAMES
Flag that can be changed to enable or disable interning of shared names; shared names are used for enumerated values to reduce memory usage. |
| pack-priv final PrefixedName | |
| pack-priv boolean | mAnyDTDppFeatures
Flag that indicates if any DTD++ features have been encountered (in DTD++-supporting mode). |
| pack-priv final boolean | mCfgFullyValidating
This flag indicates whether we should build a validating 'real' validator (true, the usual case), or a simpler pseudo-validator that can do all non-validation tasks that are based on DTD info (entity expansion, notation references, default attribute values). |
| pack-priv final boolean | |
| pack-priv boolean | mCheckForbiddenPEs
This flag is used to catch uses of PEs in the internal subset within declarations (full declarations are ok, but not other types) |
| pack-priv final int | |
| pack-priv DefaultAttrValue | mCurrAttrDefault
This is the attribute default value that is currently being parsed. |
| pack-priv String | mCurrDeclaration
Keyword of the declaration being currently parsed (if any). |
| pack-priv String | mDefaultNsURI
Currently active default namespace URI. |
| pack-priv LinkedHashMap | mElements
Contains definition of elements and matching content specifications. |
| pack-priv final DTDEventListener | |
| pack-priv boolean | mExpandingPE
Flag that indicates if the currently expanding (or last expanded) entity is a Parameter Entity or General Entity. |
| pack-priv DTDWriter | |
| pack-priv HashMap | mGeneralEntities
Set of generic entities defined so far in this subset. |
| pack-priv int | mIncludeCount
Nesting count for conditionally included sections; 0 means that we are not inside such a section. |
| pack-priv HashMap | mNamespaces
Prefix-to-NsURI mappings for this DTD, if any: lazily constructed when needed |
| pack-priv HashMap | mNotationForwardRefs
Finally, we need to keep track of Notation references that were made prior to declaration. |
| pack-priv HashMap | mNotations
Set of notations defined so far. |
| pack-priv HashMap | mParamEntities
Set of parameter entities defined so far in the currently parsed subset. |
| pack-priv final HashMap | mPredefdGEs
Set of general entities already defined for the subset being parsed; namely, PEs defined in the internal subset passed when parsing matching external subset. |
| pack-priv final HashMap | mPredefdNotations
Notations already parsed before current subset; that is, notations from the internal subset if we are currently parsing matching external subset. |
| pack-priv final HashMap | mPredefdPEs
Set of parameter entities already defined for the subset being parsed; namely, PEs defined in the internal subset passed when parsing matching external subset. |
| pack-priv Set | mRefdGEs
Set of general entities (ids) that have been referenced by this DTD; only maintained for external subsets, and only as long as no pre-defined GEs have been referenced. |
| pack-priv Set | mRefdPEs
Set of parameter entities (ids) that have been referenced by this DTD; only maintained for external subsets, and only as long as no pre-defined PE has been referenced. |
| pack-priv HashMap | mSharedEnumValues
Map used for sharing legal enumeration values; used since oftentimes same enumeration values are used with multiple attributes |
| pack-priv HashMap | mSharedNames
Map used to shared PrefixedName instances, to reduce memory usage of (qualified) element and attribute names |
| pack-priv transient TextBuffer | |
| pack-priv boolean | mUsesPredefdEntities
Flag used to keep track of whether current (external) subset has referenced at least one PE that was pre-defined. |
| pack-priv boolean | mUsesPredefdNotations
Flag used to keep track of whether current (external) subset has referenced at least one notation that was defined in internal subset. |
| pack-priv TextBuffer | mValueBuffer
Text buffer used for constructing expansion value of the internal entities, and for default attribute values. |
| Access | Constructor and Description |
|---|---|
| private | FullDTDReader(WstxInputSource input, ReaderConfig cfg, boolean constructFully, int xmlVersion)
Constructor used for reading/skipping internal subset. |
| private | FullDTDReader(WstxInputSource input, ReaderConfig cfg, DTDSubset intSubset, boolean constructFully, int xmlVersion)
Constructor used for reading external subset. |
| private | FullDTDReader(WstxInputSource input, ReaderConfig cfg, boolean isExt, DTDSubset intSubset, boolean constructFully, int xmlVersion)
Common initialization part of int/ext subset constructors. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private String | |
| protected String | checkDTDKeyword(String exp)
Method called to verify whether input has specified keyword; if it has, returns null and points to char after the keyword; if not, returns whatever constitutes a keyword matched, for error reporting purposes. |
| private void | |
| private boolean | Returns: True, if input contains 'PUBLIC' keyword; false if it contains 'SYSTEM'; otherwise throws an exception.
|
| protected void | |
| protected void | |
| private static char | |
| private char | Returns: Next character from the current input block, if any left; NULL if end of block (entity expansion)
|
| private String | |
| protected boolean | ensureInput(int minAmount)
Overrides com. Method called to make sure current main-level input buffer has at
least specified number of characters available consequtively,
without having to call |
| private String | |
| private void | |
| public EntityDecl | findEntity(String entName)
Overrides com. Method that may need to be called by attribute default value validation code, during parsing.... |
| protected EntityDecl | findEntity(String
Identifier of the entity to find id, Object If Boolean.TRUE, we are expanding a general entity arg)Overrides com. Abstract method for sub-classes to implement, for finding a declared general or parsed entity. |
| private PrefixedName | findSharedName(String prefix, String localName)
Method used to 'intern()' qualified names; main benefit is reduced memory usage as the name objects are shared. |
| public static DTDSubset | flattenExternalSubset(WstxInputSource
Input source used to read the main external subset src, Writer Writer to output processed DTD content to flattenWriter, boolean If true, will pass comments to the writer; if false,
will strip comments out inclComments, boolean If true, will include conditional block markers,
as well as intervening content; if false, will strip out both markers
and ignorable sections. inclConditionals, boolean If true, will output parameter entity declarations; if
false will parse and use them, but not output. inclPEs)Method that will parse, process and output contents of an external DTD subset. |
| private void | |
| private LinkedHashMap | |
| private char | getNextExpanded()
Method that will get next character, and either return it as is (for normal chars), or expand parameter entity that starts with next character (which has to be '%'). |
| private TextBuffer | |
| private void | |
| private void | handleAttrDecl(DTDElement
Element that contains this attribute elem, char First character of what should be the attribute name c, int Sequential index number of this attribute as children
of the element; used for creating bit masks later on. index, Location Location of the element name in attribute list declaration loc)
|
| private void | |
| private void | |
| private void | handleEntityDecl(boolean
If true, will need to take of enabling/disabling
of flattened output. suppressPEDecl)This method is tricky to implement, since it can contain parameter entities in multiple combinations... |
| private EntityDecl | handleExternalEntityDecl(WstxInputSource
Input source for the start of the declaration.
Needed for resolving relative system references, if any. inputSource, boolean True if this a parameter entity declaration; false
if general entity declaration isParam, String id, char c, Location Location where entity declaration directive started;
needed when construction event Objects for declarations. evtLoc)Method that handles rest of external entity declaration, after it's been figured out entity is not internal (does not continue with a quote). |
| protected void | |
| private void | |
| private void | |
| protected void | handleIncompleteEntityProblem(WstxInputSource closing)
Overrides com. Handling of PE matching problems is actually intricate; one type will be a WFC ("PE Between Declarations", which refers to PEs that start from outside declarations), and another just a VC ("Proper Declaration/PE Nesting", when PE is contained within declaration) |
| private void | |
| private void | handleSuppressedDeclaration()
Specialized method that handles potentially suppressable entity declaration. |
| private void | handleTargetNsDecl()
Method called to handle declaration (the only new declaration type for DTD++) Note only valid for DTD++, in 'plain DTD' mode shouldn't get called. |
| protected void | handleUndeclaredEntity(String id)
Overrides com. Undeclared parameter entity is a VC, not WFC... |
| protected void | initInputSource(WstxInputSource newInput, boolean isExt, String
Name of the entity being expanded entityId)Overrides com. Method called when an entity has been expanded (new input source has been created). |
| protected boolean | loadMore()
Overrides com. Need to override this method, to check couple of things: first, that nested input sources are balanced, when expanding parameter entities inside entity value definitions (as per XML specs), and secondly, to handle (optional) flattening output. |
| protected boolean | |
| private void | |
| private void | parseAttrDefaultValue(DefaultAttrValue defVal, char quoteChar, PrefixedName attrName, Location loc, boolean gotFixed)
This method is similar to |
| protected void | |
| protected void | parseDirectiveFlattened()
Method similar to |
| protected DTDSubset | |
| private char[] | parseEntityValue(String id, Location loc, char quoteChar)
Method that reads and pre-processes replacement text for an internal entity (parameter or generic). |
| private WordResolver | parseEnumerated(DTDElement elem, PrefixedName attrName, boolean isNotation)
Parsing method that reads a list of one or more space-separated tokens (nmtoken or name, depending on 'isNotation' argument) |
| private char | |
| protected void | readComment(DTDEventListener l)
Method similar to |
| private ContentSpec | |
| protected String | readDTDKeyword(String
Part of keyword already read in. prefix)Method called usually to indicate an error condition; will read rest of specified keyword (including characters that can be part of XML identifiers), append that to passed prefix (which is optional), and return resulting String. |
| private String | |
| private String | |
| private String | |
| private PrefixedName | readDTDQName(char firstChar)
Method that will read an element or attribute name from DTD; depending on namespace mode, it can have prefix as well. |
| private String | |
| public static DTDSubset | readExternalSubset(WstxInputSource src, ReaderConfig cfg, DTDSubset intSubset, boolean constructFully, int xmlVersion)
Method called to read in the external subset definition. |
| public static DTDSubset | readInternalSubset(WstxInputData srcData, WstxInputSource input, ReaderConfig cfg, boolean constructFully, int xmlVersion)
Method called to read in the internal subset definition. |
| private StructValidator | readMixedSpec(PrefixedName elemName, boolean
If true, will build full object for validating content
within mixed content model; if false, will just parse and discard
information (done in non-validating DTD-supporting mode) construct)Method called to parse what seems like a mixed content specification. |
| private String | readNotationEntry(char c, PrefixedName
Name of attribute in declaration that refers to this entity attrName, Location Starting location of the DTD component that contains
the reference refLoc)Method called to read a notation reference entry; done both for attributes of type NOTATION, and for external unparsed entities that refer to a notation. |
| protected void | |
| public void | setFlattenWriter(Writer w, boolean inclComments, boolean inclConditionals, boolean inclPEs)
Method that will set specified Writer as the 'flattening writer'; writer used to output flattened version of DTD read in. This is similar to running a C-preprocessor on C-sources, except that defining writer will not prevent normal parsing of DTD itself. |
| private char | |
| private char | Returns: Character following the obligatory boundary (white space or PE start/end)Note Apparently a parameter entity expansion does also count as white space (that is, PEs outside of quoted text are considered to be separated by white spaces on both sides). |
| private void | |
| private void | |
| private void | |
| private void |