Class FullDTDReader
- All Implemented Interfaces:
InputConfigFlags
,ParsingErrorMsgs
,InputProblemReporter
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).
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final Boolean
(package private) static final Boolean
(package private) static final boolean
Flag that can be changed to enable or disable interning of shared names; shared names are used for enumerated values to reduce memory usage.(package private) final PrefixedName
(package private) boolean
Flag that indicates if any DTD++ features have been encountered (in DTD++-supporting mode).(package private) final boolean
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).(package private) final boolean
(package private) boolean
This flag is used to catch uses of PEs in the internal subset within declarations (full declarations are ok, but not other types)(package private) final int
(package private) DefaultAttrValue
This is the attribute default value that is currently being parsed.(package private) String
Keyword of the declaration being currently parsed (if any).(package private) String
Currently active default namespace URI.(package private) LinkedHashMap
<PrefixedName, DTDElement> Contains definition of elements and matching content specifications.(package private) final DTDEventListener
(package private) boolean
Flag that indicates if the currently expanding (or last expanded) entity is a Parameter Entity or General Entity.(package private) DTDWriter
(package private) HashMap
<String, EntityDecl> Set of generic entities defined so far in this subset.(package private) int
Nesting count for conditionally included sections; 0 means that we are not inside such a section.Prefix-to-NsURI mappings for this DTD, if any: lazily constructed when neededFinally, we need to keep track of Notation references that were made prior to declaration.(package private) HashMap
<String, NotationDeclaration> Set of notations defined so far.(package private) HashMap
<String, EntityDecl> Set of parameter entities defined so far in the currently parsed subset.(package private) final HashMap
<String, EntityDecl> Set of general entities already defined for the subset being parsed; namely, PEs defined in the internal subset passed when parsing matching external subset.(package private) final HashMap
<String, NotationDeclaration> Notations already parsed before current subset; that is, notations from the internal subset if we are currently parsing matching external subset.(package private) final HashMap
<String, EntityDecl> Set of parameter entities already defined for the subset being parsed; namely, PEs defined in the internal subset passed when parsing matching external subset.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.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.Map used for sharing legal enumeration values; used since oftentimes same enumeration values are used with multiple attributes(package private) HashMap
<PrefixedName, PrefixedName> Map used to shared PrefixedName instances, to reduce memory usage of (qualified) element and attribute names(package private) TextBuffer
(package private) boolean
Flag used to keep track of whether current (external) subset has referenced at least one PE that was pre-defined.(package private) boolean
Flag used to keep track of whether current (external) subset has referenced at least one notation that was defined in internal subset.(package private) TextBuffer
Text buffer used for constructing expansion value of the internal entities, and for default attribute values.Fields inherited from class com.ctc.wstx.dtd.MinimalDTDReader
mIsExternal
Fields inherited from class com.ctc.wstx.sr.StreamScanner
CHAR_CR_LF_OR_NULL, CHAR_FIRST_PURE_TEXT, CHAR_LOWEST_LEGAL_LOCALNAME_CHAR, INT_CR_LF_OR_NULL, mAllowXml11EscapedCharsInXml10, mCachedEntities, mCfgNsEnabled, mCfgReplaceEntities, mCfgTreatCharRefsAsEntities, mConfig, mCurrDepth, mCurrEntity, mCurrName, mDocInputEncoding, mDocXmlEncoding, mDocXmlVersion, mEntityExpansionCount, mEntityResolver, mInput, mInputTopDepth, mNameBuffer, mNormalizeLFs, mRootInput, mTokenInputCol, mTokenInputRow, mTokenInputTotal
Fields inherited from class com.ctc.wstx.io.WstxInputData
CHAR_NULL, CHAR_SPACE, INT_NULL, INT_SPACE, MAX_UNICODE_CHAR, mCurrInputProcessed, mCurrInputRow, mCurrInputRowStart, mInputBuffer, mInputEnd, mInputPtr, mXml11
Fields inherited from interface com.ctc.wstx.cfg.InputConfigFlags
CFG_ALLOW_XML11_ESCAPED_CHARS_IN_XML10, CFG_AUTO_CLOSE_INPUT, CFG_CACHE_DTDS, CFG_CACHE_DTDS_BY_PUBLIC_ID, CFG_COALESCE_TEXT, CFG_INTERN_NAMES, CFG_INTERN_NS_URIS, CFG_JAXP_FEATURE_SECURE_PROCESSING, CFG_LAZY_PARSING, CFG_NAMESPACE_AWARE, CFG_NORMALIZE_LFS, CFG_PRESERVE_LOCATION, CFG_REPLACE_ENTITY_REFS, CFG_REPORT_CDATA, CFG_REPORT_PROLOG_WS, CFG_SUPPORT_DTD, CFG_SUPPORT_DTDPP, CFG_SUPPORT_EXTERNAL_ENTITIES, CFG_TREAT_CHAR_REFS_AS_ENTS, CFG_VALIDATE_AGAINST_DTD, CFG_XMLID_TYPING, CFG_XMLID_UNIQ_CHECKS
Fields inherited from interface com.ctc.wstx.cfg.ParsingErrorMsgs
SUFFIX_EOF_EXP_NAME, SUFFIX_IN_ATTR_VALUE, SUFFIX_IN_CDATA, SUFFIX_IN_CLOSE_ELEMENT, SUFFIX_IN_COMMENT, SUFFIX_IN_DEF_ATTR_VALUE, SUFFIX_IN_DOC, SUFFIX_IN_DTD, SUFFIX_IN_DTD_EXTERNAL, SUFFIX_IN_DTD_INTERNAL, SUFFIX_IN_ELEMENT, SUFFIX_IN_ENTITY_REF, SUFFIX_IN_EPILOG, SUFFIX_IN_NAME, SUFFIX_IN_PROC_INSTR, SUFFIX_IN_PROLOG, SUFFIX_IN_TEXT, SUFFIX_IN_XML_DECL
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
FullDTDReader
(WstxInputSource input, ReaderConfig cfg, boolean constructFully, int xmlVersion) Constructor used for reading/skipping internal subset.private
FullDTDReader
(WstxInputSource input, ReaderConfig cfg, boolean isExt, DTDSubset intSubset, boolean constructFully, int xmlVersion) Common initialization part of int/ext subset constructors.private
FullDTDReader
(WstxInputSource input, ReaderConfig cfg, DTDSubset intSubset, boolean constructFully, int xmlVersion) Constructor used for reading external subset. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private void
private void
_reportVCViolation
(String msg) private void
_reportWarning
(XMLReporter rep, String probType, String msg, Location loc) private void
private void
_reportWFCViolation
(String format, Object arg) private String
attrDesc
(Object elem, PrefixedName attrName) 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
checkPublicSystemKeyword
(char c) protected void
checkXmlIdAttr
(int type) protected void
checkXmlSpaceAttr
(int type, WordResolver enumValues) private static char
combineArities
(char arity1, char arity2) private char
private String
protected boolean
ensureInput
(int minAmount) Method called to make sure current main-level input buffer has at least specified number of characters available consequtively, without having to callStreamScanner.loadMore()
.private String
entityDesc
(WstxInputSource input) private void
expandPE()
Method called to handle expansion of parameter entities.findEntity
(String entName) Method that may need to be called by attribute default value validation code, during parsing....protected EntityDecl
findEntity
(String id, Object arg) 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.static DTDSubset
flattenExternalSubset
(WstxInputSource src, Writer flattenWriter, boolean inclComments, boolean inclConditionals, boolean inclPEs) Method that will parse, process and output contents of an external DTD subset.private void
private LinkedHashMap
<PrefixedName, DTDElement> private char
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
note: when this method is called, the keyword itself has been succesfully parsed.private void
handleAttrDecl
(DTDElement elem, char c, int index, Location loc) private void
handleDeclaration
(char c) Note: c is known to be a letter (from 'A' to 'Z') at this poit.private void
private void
handleEntityDecl
(boolean suppressPEDecl) This method is tricky to implement, since it can contain parameter entities in multiple combinations...private EntityDecl
handleExternalEntityDecl
(WstxInputSource inputSource, boolean isParam, String id, char c, Location 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
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
Method called to handle invalid input: '<!'NOTATION ...private void
Specialized method that handles potentially suppressable entity declaration.private void
Method called to handle invalid input: '<!'TARGETNS ...protected void
Undeclared parameter entity is a VC, not WFC...protected void
initInputSource
(WstxInputSource newInput, boolean isExt, String entityId) Method called when an entity has been expanded (new input source has been created).protected boolean
loadMore()
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
loadMoreScoped
(WstxInputSource currScope, String entityName, Location loc) private void
parseAttrDefaultValue
(DefaultAttrValue defVal, char quoteChar, PrefixedName attrName, Location loc, boolean gotFixed) This method is similar toparseEntityValue(java.lang.String, javax.xml.stream.Location, char)
in some ways, but has some notable differences, due to the way XML specs define differences.protected void
protected void
Method similar toparseDirective()
, but one that takes care to properly output dtd contents usingcom.ctc.wstx.dtd.DTDWriter
as necessary.protected DTDSubset
parseDTD()
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
Method similar toMinimalDTDReader.skipComment()
, but that has to collect contents, to be reported for a SAX handler.private ContentSpec
readContentSpec
(PrefixedName elemName, boolean mainLevel, boolean construct) protected String
readDTDKeyword
(String 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
readDTDLocalName
(char c, boolean checkChar) private String
readDTDName
(char c) private String
readDTDNmtoken
(char c) Similar toreadDTDName(char)
, except that the rules are bit looser, ie.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
readEnumEntry
(char c, HashMap<String, String> sharedEnums) static DTDSubset
readExternalSubset
(WstxInputSource src, ReaderConfig cfg, DTDSubset intSubset, boolean constructFully, int xmlVersion) Method called to read in the external subset definition.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 construct) Method called to parse what seems like a mixed content specification.private String
readNotationEntry
(char c, PrefixedName attrName, Location 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
readPI()
Method similar toMinimalDTDReader.skipPI()
, but one that does basic well-formedness checks.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.private char
skipDtdWs
(boolean handlePEs) private char
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
throwDTDAttrError
(String msg, DTDElement elem, PrefixedName attrName) private void
throwDTDElemError
(String msg, Object elem) private void
throwDTDUnexpectedChar
(int i, String extraMsg) private void
Methods inherited from class com.ctc.wstx.dtd.MinimalDTDReader
dtdNextChar, dtdNextFromCurr, getErrorMsg, getLocation, getNextSkippingPEs, handleExpandedSurrogate, skipComment, skipCommentContent, skipInternalSubset, skipInternalSubset, skipPI, throwIllegalCall
Methods inherited from class com.ctc.wstx.sr.StreamScanner
_reportProblem, _reportProblem, closeAllInput, constructFromIOE, constructLimitViolation, constructNullCharException, constructWfcException, expandBy50Pct, expandEntity, fullyResolveEntity, getConfig, getCurrentInput, getCurrentLocation, getIntEntity, getLastCharLocation, getNameBuffer, getNext, getNextAfterWS, getNextChar, getNextCharAfterWS, getNextCharFromCurrent, getNextInCurrAfterWS, getNextInCurrAfterWS, getSource, getStartLocation, getSystemId, inputInBuffer, loadMore, loadMoreFromCurrent, markLF, markLF, parseEntityName, parseFNameForError, parseFullName, parseFullName, parseFullName2, parseLocalName, parseLocalName2, parsePublicId, parseSystemId, parseUntil, peekNext, pushback, reportProblem, reportProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, resolveCharOnlyEntity, resolveNonCharEntity, resolveSimpleEntity, skipCRLF, skipFullName, throwFromIOE, throwFromStrE, throwInvalidSpace, throwInvalidSpace, throwLazyError, throwNullChar, throwNullParent, throwParseError, throwParseError, throwUnexpectedChar, throwUnexpectedEOB, throwUnexpectedEOF, throwWfcException, tokenTypeDesc, verifyLimit
Methods inherited from class com.ctc.wstx.io.WstxInputData
copyBufferStateFrom, findIllegalNameChar, findIllegalNmtokenChar, getCharDesc, isNameChar, isNameChar, isNameStartChar, isNameStartChar, isSpaceChar
-
Field Details
-
INTERN_SHARED_NAMES
static final boolean INTERN_SHARED_NAMESFlag that can be changed to enable or disable interning of shared names; shared names are used for enumerated values to reduce memory usage.- See Also:
-
ENTITY_EXP_GE
-
ENTITY_EXP_PE
-
mConfigFlags
final int mConfigFlags -
mCfgSupportDTDPP
final boolean mCfgSupportDTDPP -
mCfgFullyValidating
final boolean mCfgFullyValidatingThis 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). Latter is used in non-validating mode. -
mParamEntities
HashMap<String,EntityDecl> mParamEntitiesSet of parameter entities defined so far in the currently parsed subset. Note: the first definition sticks, entities can not be redefined.Keys are entity name Strings; values are instances of EntityDecl
-
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. Null when parsing internal subset. -
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. -
mGeneralEntities
HashMap<String,EntityDecl> mGeneralEntitiesSet of generic entities defined so far in this subset. As with parameter entities, the first definition sticks.Keys are entity name Strings; values are instances of EntityDecl
Note: this Map only contains entities declared and defined in the subset being parsed; no previously defined values are passed.
-
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. Null when parsing internal subset. Such entities are only needed directly for one purpose; to be expanded when reading attribute default value definitions. -
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. -
mUsesPredefdEntities
boolean mUsesPredefdEntitiesFlag used to keep track of whether current (external) subset has referenced at least one PE that was pre-defined. -
mNotations
HashMap<String,NotationDeclaration> mNotationsSet of notations defined so far. Since it's illegal to (try to) redefine notations, there's no specific precedence.Keys are entity name Strings; values are instances of NotationDecl objects
-
mPredefdNotations
Notations already parsed before current subset; that is, notations from the internal subset if we are currently parsing matching external subset. -
mUsesPredefdNotations
boolean mUsesPredefdNotationsFlag used to keep track of whether current (external) subset has referenced at least one notation that was defined in internal subset. If so, can not cache the external subset -
mNotationForwardRefs
Finally, we need to keep track of Notation references that were made prior to declaration. This is needed to ensure that all references can be properly resolved. -
mElements
LinkedHashMap<PrefixedName,DTDElement> mElementsContains definition of elements and matching content specifications. Also contains temporary placeholders for elements that are indirectly "created" by ATTLIST declarations that precede actual declaration for the ELEMENT referred to. -
mCurrAttrDefault
DefaultAttrValue mCurrAttrDefaultThis is the attribute default value that is currently being parsed. Needs to be a global member due to the way entity expansion failures are reported: problems need to be attached to this object, even thought the default value itself will not be passed through. -
mExpandingPE
boolean mExpandingPEFlag that indicates if the currently expanding (or last expanded) entity is a Parameter Entity or General Entity. -
mValueBuffer
TextBuffer mValueBufferText buffer used for constructing expansion value of the internal entities, and for default attribute values. Lazily constructed when needed, reused. -
mIncludeCount
int mIncludeCountNesting count for conditionally included sections; 0 means that we are not inside such a section. Note that condition ignore is handled separately. -
mCheckForbiddenPEs
boolean mCheckForbiddenPEsThis flag is used to catch uses of PEs in the internal subset within declarations (full declarations are ok, but not other types) -
mCurrDeclaration
String mCurrDeclarationKeyword of the declaration being currently parsed (if any). Can be used for error reporting purposes. -
mAnyDTDppFeatures
boolean mAnyDTDppFeaturesFlag that indicates if any DTD++ features have been encountered (in DTD++-supporting mode). -
mDefaultNsURI
String mDefaultNsURICurrently active default namespace URI. -
mNamespaces
Prefix-to-NsURI mappings for this DTD, if any: lazily constructed when needed -
mFlattenWriter
DTDWriter mFlattenWriter -
mEventListener
-
mTextBuffer
-
mAccessKey
-
-
Constructor Details
-
FullDTDReader
private FullDTDReader(WstxInputSource input, ReaderConfig cfg, boolean constructFully, int xmlVersion) Constructor used for reading/skipping internal subset. -
FullDTDReader
private FullDTDReader(WstxInputSource input, ReaderConfig cfg, DTDSubset intSubset, boolean constructFully, int xmlVersion) Constructor used for reading external subset. -
FullDTDReader
private FullDTDReader(WstxInputSource input, ReaderConfig cfg, boolean isExt, DTDSubset intSubset, boolean constructFully, int xmlVersion) Common initialization part of int/ext subset constructors.
-
-
Method Details
-
readInternalSubset
public static DTDSubset readInternalSubset(WstxInputData srcData, WstxInputSource input, ReaderConfig cfg, boolean constructFully, int xmlVersion) throws XMLStreamException Method called to read in the internal subset definition.- Throws:
XMLStreamException
-
readExternalSubset
public static DTDSubset readExternalSubset(WstxInputSource src, ReaderConfig cfg, DTDSubset intSubset, boolean constructFully, int xmlVersion) throws XMLStreamException Method called to read in the external subset definition.- Throws:
XMLStreamException
-
flattenExternalSubset
public static DTDSubset flattenExternalSubset(WstxInputSource src, Writer flattenWriter, boolean inclComments, boolean inclConditionals, boolean inclPEs) throws IOException, XMLStreamException Method that will parse, process and output contents of an external DTD subset. It will do processing similar toreadExternalSubset(com.ctc.wstx.io.WstxInputSource, com.ctc.wstx.api.ReaderConfig, com.ctc.wstx.dtd.DTDSubset, boolean, int)
, but additionally will copy its processed ("flattened") input to specified writer.- Parameters:
src
- Input source used to read the main external subsetflattenWriter
- Writer to output processed DTD content toinclComments
- If true, will pass comments to the writer; if false, will strip comments outinclConditionals
- If true, will include conditional block markers, as well as intervening content; if false, will strip out both markers and ignorable sections.inclPEs
- If true, will output parameter entity declarations; if false will parse and use them, but not output.- Throws:
IOException
XMLStreamException
-
getTextBuffer
-
setFlattenWriter
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. -
flushFlattenWriter
- Throws:
XMLStreamException
-
findEntity
Method that may need to be called by attribute default value validation code, during parsing....Note: see base class for some additional remarks about this method.
- Overrides:
findEntity
in classMinimalDTDReader
-
parseDTD
- Throws:
XMLStreamException
-
parseDirective
- Throws:
XMLStreamException
-
parseDirectiveFlattened
Method similar toparseDirective()
, but one that takes care to properly output dtd contents usingcom.ctc.wstx.dtd.DTDWriter
as necessary. Separated to simplify both methods; otherwise would end up with 'if (... flatten...) ... else ...' spaghetti code.- Throws:
XMLStreamException
-
initInputSource
protected void initInputSource(WstxInputSource newInput, boolean isExt, String entityId) throws XMLStreamException Description copied from class:StreamScanner
Method called when an entity has been expanded (new input source has been created). Needs to initialize location information and change active input source.- Overrides:
initInputSource
in classStreamScanner
- Parameters:
entityId
- Name of the entity being expanded- Throws:
XMLStreamException
-
loadMore
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.- Overrides:
loadMore
in classStreamScanner
- Returns:
- true if reading succeeded (or may succeed), false if we reached EOF.
- Throws:
XMLStreamException
-
loadMoreFromCurrent
- Overrides:
loadMoreFromCurrent
in classStreamScanner
- Throws:
XMLStreamException
-
ensureInput
Description copied from class:StreamScanner
Method called to make sure current main-level input buffer has at least specified number of characters available consequtively, without having to callStreamScanner.loadMore()
. It can only be called when input comes from main-level buffer; further, call can shift content in input buffer, so caller has to flush any data still pending. In short, caller has to know exactly what it's doing. :-)Note: method does not check for any other input sources than the current one -- if current source can not fulfill the request, a failure is indicated.
- Overrides:
ensureInput
in classStreamScanner
- Returns:
- true if there's now enough data; false if not (EOF)
- Throws:
XMLStreamException
-
loadMoreScoped
private void loadMoreScoped(WstxInputSource currScope, String entityName, Location loc) throws XMLStreamException - Throws:
XMLStreamException
-
dtdNextIfAvailable
- Returns:
- Next character from the current input block, if any left; NULL if end of block (entity expansion)
- Throws:
XMLStreamException
-
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 '%').- Throws:
XMLStreamException
-
skipDtdWs
- Throws:
XMLStreamException
-
skipObligatoryDtdWs
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). Fortunately this can be handled by 2 little hacks: both a start of a PE, and an end of input block (== end of PE expansion) count as succesful spaces.- Returns:
- Character following the obligatory boundary (white space or PE start/end)
- Throws:
XMLStreamException
-
expandPE
Method called to handle expansion of parameter entities. When called, '%' character has been encountered as a reference indicator, and now we should get parameter entity name.- Throws:
XMLStreamException
-
checkDTDKeyword
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.- Throws:
XMLStreamException
-
readDTDKeyword
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.- Parameters:
prefix
- Part of keyword already read in.- Throws:
XMLStreamException
-
checkPublicSystemKeyword
- Returns:
- True, if input contains 'PUBLIC' keyword; false if it contains 'SYSTEM'; otherwise throws an exception.
- Throws:
XMLStreamException
-
readDTDName
- Throws:
XMLStreamException
-
readDTDLocalName
- Throws:
XMLStreamException
-
readDTDNmtoken
Similar toreadDTDName(char)
, except that the rules are bit looser, ie. there are no additional restrictions for the first char- Throws:
XMLStreamException
-
readDTDQName
Method that will read an element or attribute name from DTD; depending on namespace mode, it can have prefix as well.Note: returned
PrefixedName
instances are canonicalized so that all instances read during parsing of a single DTD subset so that identity comparison can be used instead of callingequals()
method (but only within a single subset!). This also reduces memory usage to some extent.- Throws:
XMLStreamException
-
readArity
- Throws:
XMLStreamException
-
parseEntityValue
Method that reads and pre-processes replacement text for an internal entity (parameter or generic).- Throws:
XMLStreamException
-
parseAttrDefaultValue
private void parseAttrDefaultValue(DefaultAttrValue defVal, char quoteChar, PrefixedName attrName, Location loc, boolean gotFixed) throws XMLStreamException This method is similar toparseEntityValue(java.lang.String, javax.xml.stream.Location, char)
in some ways, but has some notable differences, due to the way XML specs define differences. Main differences are that parameter entities are not allowed (or rather, recognized as entities), and that general entities need to be verified, but NOT expanded right away. Whether forward references are allowed or not is an open question right now.- Throws:
XMLStreamException
-
readPI
Method similar toMinimalDTDReader.skipPI()
, but one that does basic well-formedness checks.- Throws:
XMLStreamException
-
readComment
Method similar toMinimalDTDReader.skipComment()
, but that has to collect contents, to be reported for a SAX handler.- Throws:
XMLStreamException
-
checkInclusion
- Throws:
XMLStreamException
-
handleIncluded
- Throws:
XMLStreamException
-
handleIgnored
- Throws:
XMLStreamException
-
_reportUndefinedNotationRefs
- Throws:
XMLStreamException
-
_reportBadDirective
- Throws:
XMLStreamException
-
_reportVCViolation
- Throws:
XMLStreamException
-
_reportWFCViolation
- Throws:
XMLStreamException
-
_reportWFCViolation
- Throws:
XMLStreamException
-
throwDTDElemError
- Throws:
XMLStreamException
-
throwDTDAttrError
private void throwDTDAttrError(String msg, DTDElement elem, PrefixedName attrName) throws XMLStreamException - Throws:
XMLStreamException
-
throwDTDUnexpectedChar
- Throws:
XMLStreamException
-
throwForbiddenPE
- Throws:
XMLStreamException
-
elemDesc
-
attrDesc
-
entityDesc
-
handleDeclaration
Note: c is known to be a letter (from 'A' to 'Z') at this poit.
- Throws:
XMLStreamException
-
handleSuppressedDeclaration
Specialized method that handles potentially suppressable entity declaration. Specifically: at this point it is known that first letter is 'E', that we are outputting flattened DTD info, and that parameter entity declarations are to be suppressed. Furthermore, flatten output is still being disabled, and needs to be enabled by the method at some point.- Throws:
XMLStreamException
-
handleAttlistDecl
note: when this method is called, the keyword itself has been succesfully parsed.- Throws:
XMLStreamException
-
handleElementDecl
- Throws:
XMLStreamException
-
handleEntityDecl
This method is tricky to implement, since it can contain parameter entities in multiple combinations... and yet declare one as well.- Parameters:
suppressPEDecl
- If true, will need to take of enabling/disabling of flattened output.- Throws:
XMLStreamException
-
handleNotationDecl
Method called to handle invalid input: '<!'NOTATION ... > declaration.- Throws:
XMLStreamException
-
handleTargetNsDecl
Method called to handle invalid input: '<!'TARGETNS ... > declaration (the only new declaration type for DTD++)Note: only valid for DTD++, in 'plain DTD' mode shouldn't get called.
- Throws:
XMLStreamException
-
handleAttrDecl
private void handleAttrDecl(DTDElement elem, char c, int index, Location loc) throws XMLStreamException - Parameters:
elem
- Element that contains this attributec
- First character of what should be the attribute nameindex
- Sequential index number of this attribute as children of the element; used for creating bit masks later on.loc
- Location of the element name in attribute list declaration- Throws:
XMLStreamException
-
parseEnumerated
private WordResolver parseEnumerated(DTDElement elem, PrefixedName attrName, boolean isNotation) throws XMLStreamException Parsing method that reads a list of one or more space-separated tokens (nmtoken or name, depending on 'isNotation' argument)- Throws:
XMLStreamException
-
readNotationEntry
private String readNotationEntry(char c, PrefixedName attrName, Location refLoc) throws XMLStreamException 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. In both cases, notation referenced needs to have been defined earlier; but only if we are building a fully validating DTD subset object (there is the alternative of a minimal DTD in DTD-aware mode, which does no validation but allows attribute defaulting and normalization, as well as access to entity and notation declarations).- Parameters:
attrName
- Name of attribute in declaration that refers to this entityrefLoc
- Starting location of the DTD component that contains the reference- Throws:
XMLStreamException
-
readEnumEntry
- Throws:
XMLStreamException
-
readMixedSpec
private StructValidator readMixedSpec(PrefixedName elemName, boolean construct) throws XMLStreamException Method called to parse what seems like a mixed content specification.- Parameters:
construct
- 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)- Throws:
XMLStreamException
-
readContentSpec
private ContentSpec readContentSpec(PrefixedName elemName, boolean mainLevel, boolean construct) throws XMLStreamException - Parameters:
mainLevel
- Whether this is the main-level content specification or nested- Throws:
XMLStreamException
-
combineArities
private static char combineArities(char arity1, char arity2) -
handleExternalEntityDecl
private EntityDecl handleExternalEntityDecl(WstxInputSource inputSource, boolean isParam, String id, char c, Location evtLoc) throws XMLStreamException Method that handles rest of external entity declaration, after it's been figured out entity is not internal (does not continue with a quote).- Parameters:
inputSource
- Input source for the start of the declaration. Needed for resolving relative system references, if any.isParam
- True if this a parameter entity declaration; false if general entity declarationevtLoc
- Location where entity declaration directive started; needed when construction event Objects for declarations.- Throws:
XMLStreamException
-
getElementMap
-
findEntity
Description copied from class:StreamScanner
Abstract method for sub-classes to implement, for finding a declared general or parsed entity.- Overrides:
findEntity
in classMinimalDTDReader
- Parameters:
id
- Identifier of the entity to findarg
- If Boolean.TRUE, we are expanding a general entity
-
handleUndeclaredEntity
Undeclared parameter entity is a VC, not WFC...- Overrides:
handleUndeclaredEntity
in classMinimalDTDReader
- Throws:
XMLStreamException
-
handleIncompleteEntityProblem
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)- Overrides:
handleIncompleteEntityProblem
in classMinimalDTDReader
- Throws:
XMLStreamException
-
handleGreedyEntityProblem
- Throws:
XMLStreamException
-
checkXmlSpaceAttr
- Throws:
XMLStreamException
-
checkXmlIdAttr
- Throws:
XMLStreamException
-
_reportWarning
private void _reportWarning(XMLReporter rep, String probType, String msg, Location loc) throws XMLStreamException - Throws:
XMLStreamException
-