protected void parseDirectiveFlattened()
        throws XMLStreamException
    {
        /* First, need to flush any flattened output there may be, at
         * this point (except for opening lt char): and then need to
         * temporarily disable more output until we know the type and
         * whether it should be output or not:
         */
        mFlattenWriter.flush(mInputBuffer, mInputPtr-1);
        mFlattenWriter.disableOutput();

        /* Let's determine type here, and call appropriate skip/parse
         * methods.
         */
        char c = dtdNextFromCurr();
        if (c == '?') { // xml decl?
            mFlattenWriter.enableOutput(mInputPtr);
            mFlattenWriter.output("<?");
            readPI();
            //throwDTDUnexpectedChar(c, " expected '!' to start a directive");
            return;
        }
        if (c != '!') { // nothing valid
            throwDTDUnexpectedChar(c, ErrorConsts.ERR_DTD_MAINLEVEL_KEYWORD);
        }

        // ignore/include, comment, or directive

        c = dtdNextFromCurr();
        if (c == '-') { // plain comment
            c = dtdNextFromCurr();
            if (c != '-') {
                throwDTDUnexpectedChar(c, "; expected '-' for a comment");
            }
            boolean comm = mFlattenWriter.includeComments();
            if (comm) {
                mFlattenWriter.enableOutput(mInputPtr);
                mFlattenWriter.output("<!--");
            }

            try {
                skipComment();
            } finally {
                if (!comm) {
                    mFlattenWriter.enableOutput(mInputPtr);
                }
            }
        } else {
            if (c == '[') {
                boolean cond = mFlattenWriter.includeConditionals();
                if (cond) {
                    mFlattenWriter.enableOutput(mInputPtr);
                    mFlattenWriter.output("<![");
                }
                try {
                    checkInclusion();
                } finally {
                    if (!cond) {
                        mFlattenWriter.enableOutput(mInputPtr);
                    }
                }
            } else {
                /* 12-Jul-2004, TSa: Do we need to see if we have to suppress
                 *    a PE declaration?
                 */
                boolean filterPEs = (c == 'E') && !mFlattenWriter.includeParamEntities();
                if (filterPEs) {
                    handleSuppressedDeclaration();
                } else if (c >= 'A' && c <= 'Z') {
                    mFlattenWriter.enableOutput(mInputPtr);
                    mFlattenWriter.output("<!");
                    mFlattenWriter.output(c);
                    handleDeclaration(c);
                } else {
                    throwDTDUnexpectedChar(c, ErrorConsts.ERR_DTD_MAINLEVEL_KEYWORD);
                }
            }
        }
    }
protected void parseDirectiveFlattened ( ) throws XMLStreamException { mFlattenWriter . flush ( mInputBuffer , mInputPtr - 1 ) ; mFlattenWriter . disableOutput ( ) ; char c = dtdNextFromCurr ( ) ; if ( c == '?' ) { mFlattenWriter . enableOutput ( mInputPtr ) ; mFlattenWriter . output ( "<?" ) ; readPI ( ) ; return ; } if ( c != '!' ) { throwDTDUnexpectedChar ( c , ErrorConsts . ERR_DTD_MAINLEVEL_KEYWORD ) ; } c = dtdNextFromCurr ( ) ; if ( c == '-' ) { c = dtdNextFromCurr ( ) ; if ( c != '-' ) { throwDTDUnexpectedChar ( c , "; expected '-' for a comment" ) ; } boolean comm = mFlattenWriter . includeComments ( ) ; if ( comm ) { mFlattenWriter . enableOutput ( mInputPtr ) ; mFlattenWriter . output ( "<!--" ) ; } try { skipComment ( ) ; } finally { if ( ! comm ) { mFlattenWriter . enableOutput ( mInputPtr ) ; } } } else { if ( c == '[' ) { boolean cond = mFlattenWriter . includeConditionals ( ) ; if ( cond ) { mFlattenWriter . enableOutput ( mInputPtr ) ; mFlattenWriter . output ( "<![" ) ; } try { checkInclusion ( ) ; } finally { if ( ! cond ) { mFlattenWriter . enableOutput ( mInputPtr ) ; } } } else { boolean filterPEs = ( c == 'E' ) && ! mFlattenWriter . includeParamEntities ( ) ; if ( filterPEs ) { handleSuppressedDeclaration ( ) ; } else if ( c >= 'A' && c <= 'Z' ) { mFlattenWriter . enableOutput ( mInputPtr ) ; mFlattenWriter . output ( "<!" ) ; mFlattenWriter . output ( c ) ; handleDeclaration ( c ) ; } else { throwDTDUnexpectedChar ( c , ErrorConsts . ERR_DTD_MAINLEVEL_KEYWORD ) ; } } } }
Method similar to {@link #parseDirective}, but one that takes care
to properly output dtd contents via {@link com.ctc.wstx.dtd.DTDWriter}
as necessary.
Separated to simplify both methods; otherwise would end up with
'if (... flatten...) ... else ...' spaghetti code.