|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ctc.wstx.io.WstxInputData
com.ctc.wstx.sr.StreamScanner
com.ctc.wstx.dtd.MinimalDTDReader
com.ctc.wstx.dtd.FullDTDReader
Reader that reads in DTD information from internal or external subset. It also implements simple stand-alone functionality for flattening DTD files; this is sometimes useful when optimizing modularized DTDs (which are more maintainable) into single monolithic DTDs (which in general can be more performant).
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.
| Field Summary |
| 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, mCfgNsEnabled, mConfig, mInput, mNameBuffer, mReporter, mRootInput, mTextBuffer, 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, mInputLen, mInputPtr |
| Method Summary | |
protected java.lang.String |
checkDTDKeyword(java.lang.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. |
protected void |
checkDTDKeyword(java.lang.String exp,
char firstChar,
java.lang.String extraError)
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. |
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 call loadMore(). |
EntityDecl |
findEntity(java.lang.String entName)
Method that may need to be called by attribute default value validation code, during parsing.... |
static DTDSubset |
flattenExternalSubset(WstxInputSource src,
java.io.Writer flattenWriter,
boolean inclComments,
boolean inclConditionals,
boolean inclPEs)
Method that will parse, process and output contents of an external DTD subset. |
protected void |
initInputSource(WstxInputSource newInput,
boolean isExt)
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 |
loadMoreFromCurrent()
|
protected void |
parseDirective()
|
protected void |
parseDirectiveFlattened()
Method similar to parseDirective(), but one that takes care
to properly output dtd contents via DTDWriter
as necessary. |
protected DTDSubset |
parseDTD()
|
protected java.lang.String |
readDTDKeyword(java.lang.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. |
static DTDSubset |
readExternalSubset(StreamScanner master,
WstxInputSource src,
ReaderConfig cfg,
DTDSubset intSubset)
Method called to read in the external subset definition. |
static DTDSubset |
readInternalSubset(StreamScanner master,
WstxInputSource input,
ReaderConfig cfg)
Method called to read in the internal subset definition. |
void |
setFlattenWriter(java.io.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. |
| Methods inherited from class com.ctc.wstx.dtd.MinimalDTDReader |
getErrorMsg, getLocation, getNextSkippingPEs, skipComment, skipCommentContent, skipInternalSubset, skipInternalSubset, skipPI |
| Methods inherited from class com.ctc.wstx.io.WstxInputData |
copyBufferStateFrom, getCharDesc, is11NameChar, is11NameStartChar, isSpaceChar |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static DTDSubset readInternalSubset(StreamScanner master,
WstxInputSource input,
ReaderConfig cfg)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
public static DTDSubset readExternalSubset(StreamScanner master,
WstxInputSource src,
ReaderConfig cfg,
DTDSubset intSubset)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
public static DTDSubset flattenExternalSubset(WstxInputSource src,
java.io.Writer flattenWriter,
boolean inclComments,
boolean inclConditionals,
boolean inclPEs)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
readExternalSubset(com.ctc.wstx.sr.StreamScanner, com.ctc.wstx.io.WstxInputSource, com.ctc.wstx.api.ReaderConfig, com.ctc.wstx.dtd.DTDSubset), but additionally will copy its processed
("flattened") input to specified writer.
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.
java.io.IOException
javax.xml.stream.XMLStreamException
public void setFlattenWriter(java.io.Writer w,
boolean inclComments,
boolean inclConditionals,
boolean inclPEs)
public EntityDecl findEntity(java.lang.String entName)
Note: see base class for some additional remarks about this method.
findEntity in class MinimalDTDReader
protected DTDSubset parseDTD()
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected void parseDirective()
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected void parseDirectiveFlattened()
throws java.io.IOException,
javax.xml.stream.XMLStreamException
parseDirective(), but one that takes care
to properly output dtd contents via DTDWriter
as necessary.
Separated to simplify both methods; otherwise would end up with
'if (... flatten...) ... else ...' spaghetti code.
java.io.IOException
javax.xml.stream.XMLStreamException
protected void initInputSource(WstxInputSource newInput,
boolean isExt)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
StreamScanner
initInputSource in class StreamScannerjava.io.IOException
javax.xml.stream.XMLStreamException
protected boolean loadMore()
throws java.io.IOException,
WstxException
loadMore in class StreamScannerjava.io.IOException
WstxException
protected boolean loadMoreFromCurrent()
throws java.io.IOException,
WstxException
loadMoreFromCurrent in class StreamScannerjava.io.IOException
WstxException
protected boolean ensureInput(int minAmount)
throws java.io.IOException
StreamScannerStreamScanner.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.
ensureInput in class StreamScannerjava.io.IOException
protected java.lang.String checkDTDKeyword(java.lang.String exp)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected void checkDTDKeyword(java.lang.String exp,
char firstChar,
java.lang.String extraError)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected java.lang.String readDTDKeyword(java.lang.String prefix)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
prefix - Part of keyword already read in, if any; may be null
if keyword is just starting.
java.io.IOException
javax.xml.stream.XMLStreamException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||