⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmldtdscannerimpl.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        }        return defaultType;            } // ScanAttDefaultDecl        /**     * Scans an entity declaration     * <p>     * <pre>     * [70]    EntityDecl  ::=    GEDecl | PEDecl     * [71]    GEDecl      ::=    '&lt;!ENTITY' S Name S EntityDef S? '>'     * [72]    PEDecl      ::=    '&lt;!ENTITY' S '%' S Name S PEDef S? '>'     * [73]    EntityDef   ::=    EntityValue | (ExternalID NDataDecl?)     * [74]    PEDef       ::=    EntityValue | ExternalID     * [75]    ExternalID  ::=    'SYSTEM' S SystemLiteral     *                          | 'PUBLIC' S PubidLiteral S SystemLiteral     * [76]    NDataDecl   ::=    S 'NDATA' S Name     * </pre>     * <p>     * <strong>Note:</strong> Called after scanning past '&lt;!ENTITY'     */    private final void scanEntityDecl() throws IOException, XNIException {                boolean isPEDecl = false;        boolean sawPERef = false;        fReportEntity = false;        if (fEntityScanner.skipSpaces()) {            if (!fEntityScanner.skipChar('%')) {                isPEDecl = false; // <!ENTITY x "x">            }            else if (skipSeparator(true, !scanningInternalSubset())) {                // <!ENTITY % x "x">                isPEDecl = true;            }            else if (scanningInternalSubset()) {                reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL",                null);                isPEDecl = true;            }            else if (fEntityScanner.peekChar() == '%') {                // <!ENTITY %%x; "x"> is legal                skipSeparator(false, !scanningInternalSubset());                isPEDecl = true;            }            else {                sawPERef = true;            }        }        else if (scanningInternalSubset() || !fEntityScanner.skipChar('%')) {            // <!ENTITY[^ ]...> or <!ENTITY[^ %]...>            reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL",            null);            isPEDecl = false;        }        else if (fEntityScanner.skipSpaces()) {            // <!ENTITY% ...>            reportFatalError("MSG_SPACE_REQUIRED_BEFORE_PERCENT_IN_PEDECL",            null);            isPEDecl = false;        }        else {            sawPERef = true;        }        if (sawPERef) {            while (true) {                String peName = fEntityScanner.scanName();                if (peName == null) {                    reportFatalError("NameRequiredInPEReference", null);                }                else if (!fEntityScanner.skipChar(';')) {                    reportFatalError("SemicolonRequiredInPEReference",                    new Object[]{peName});                }                else {                    startPE(peName, false);                }                fEntityScanner.skipSpaces();                if (!fEntityScanner.skipChar('%'))                    break;                if (!isPEDecl) {                    if (skipSeparator(true, !scanningInternalSubset())) {                        isPEDecl = true;                        break;                    }                    isPEDecl = fEntityScanner.skipChar('%');                }            }        }                // name        String name = fEntityScanner.scanName();        if (name == null) {            reportFatalError("MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL", null);        }                // spaces        if (!skipSeparator(true, !scanningInternalSubset())) {            reportFatalError("MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL",            new Object[]{name});        }                // external id        scanExternalID(fStrings, false);        String systemId = fStrings[0];        String publicId = fStrings[1];                if (isPEDecl && systemId != null) {            fSeenExternalPE = true;        }                String notation = null;        // NDATA        boolean sawSpace = skipSeparator(true, !scanningInternalSubset());        if (!isPEDecl && fEntityScanner.skipString("NDATA")) {            // check whether there was space before NDATA            if (!sawSpace) {                reportFatalError("MSG_SPACE_REQUIRED_BEFORE_NDATA_IN_UNPARSED_ENTITYDECL",                new Object[]{name});            }                        // spaces            if (!skipSeparator(true, !scanningInternalSubset())) {                reportFatalError("MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_UNPARSED_ENTITYDECL",                new Object[]{name});            }            notation = fEntityScanner.scanName();            if (notation == null) {                reportFatalError("MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL",                new Object[]{name});            }        }                // internal entity        if (systemId == null) {            scanEntityValue(fLiteral, fLiteral2);            // since we need it's value anyway, let's snag it so it doesn't get corrupted            // if a new load takes place before we store the entity values            fStringBuffer.clear();            fStringBuffer2.clear();            fStringBuffer.append(fLiteral.ch, fLiteral.offset, fLiteral.length);            fStringBuffer2.append(fLiteral2.ch, fLiteral2.offset, fLiteral2.length);        }                // skip possible trailing space        skipSeparator(false, !scanningInternalSubset());                // end        if (!fEntityScanner.skipChar('>')) {            reportFatalError("EntityDeclUnterminated", new Object[]{name});        }        fMarkUpDepth--;                // register entity and make callback        if (isPEDecl) {            name = "%" + name;        }        if (systemId != null) {            String baseSystemId = fEntityScanner.getBaseSystemId();            if (notation != null) {                fEntityStore.addUnparsedEntity(name, publicId, systemId, baseSystemId, notation);            }            else {                fEntityStore.addExternalEntity(name, publicId, systemId,                baseSystemId);            }            if (fDTDHandler != null) {                //Venu Revisit : why false has been removed in expandSYstem                fResourceIdentifier.setValues(publicId, systemId, baseSystemId, XMLEntityManager.expandSystemId(systemId, baseSystemId ));                                if (notation != null) {                    fDTDHandler.unparsedEntityDecl(name, fResourceIdentifier,                    notation, null);                }                else {                    fDTDHandler.externalEntityDecl(name, fResourceIdentifier, null);                }            }        }        else {            fEntityStore.addInternalEntity(name, fStringBuffer.toString());            if (fDTDHandler != null) {                fDTDHandler.internalEntityDecl(name, fStringBuffer, fStringBuffer2, null);            }        }        fReportEntity = true;            } // scanEntityDecl()        /**     * Scans an entity value.     *     * @param value The string to fill in with the value.     * @param nonNormalizedValue The string to fill in with the     *                           non-normalized value.     *     * <strong>Note:</strong> This method uses fString, fStringBuffer (through     * the use of scanCharReferenceValue), and fStringBuffer2, anything in them     * at the time of calling is lost.     */    protected final void scanEntityValue(XMLString value,    XMLString nonNormalizedValue)    throws IOException, XNIException {        int quote = fEntityScanner.scanChar();        if (quote != '\'' && quote != '"') {            reportFatalError("OpenQuoteMissingInDecl", null);        }        // store at which depth of entities we start        int entityDepth = fEntityDepth;                XMLString literal = fString;        XMLString literal2 = fString;        if (fEntityScanner.scanLiteral(quote, fString) != quote) {            fStringBuffer.clear();            fStringBuffer2.clear();            do {                fStringBuffer.append(fString);                fStringBuffer2.append(fString);                if (fEntityScanner.skipChar('&')) {                    if (fEntityScanner.skipChar('#')) {                        fStringBuffer2.append("&#");                        scanCharReferenceValue(fStringBuffer, fStringBuffer2);                    }                    else {                        fStringBuffer.append('&');                        fStringBuffer2.append('&');                        String eName = fEntityScanner.scanName();                        if (eName == null) {                            reportFatalError("NameRequiredInReference",                            null);                        }                        else {                            fStringBuffer.append(eName);                            fStringBuffer2.append(eName);                        }                        if (!fEntityScanner.skipChar(';')) {                            reportFatalError("SemicolonRequiredInReference",                            new Object[]{eName});                        }                        else {                            fStringBuffer.append(';');                            fStringBuffer2.append(';');                        }                    }                }                else if (fEntityScanner.skipChar('%')) {                    while (true) {                        fStringBuffer2.append('%');                        String peName = fEntityScanner.scanName();                        if (peName == null) {                            reportFatalError("NameRequiredInPEReference",                            null);                        }                        else if (!fEntityScanner.skipChar(';')) {                            reportFatalError("SemicolonRequiredInPEReference",                            new Object[]{peName});                        }                        else {                            if (scanningInternalSubset()) {                                reportFatalError("PEReferenceWithinMarkup",                                new Object[]{peName});                            }                            fStringBuffer2.append(peName);                            fStringBuffer2.append(';');                        }                        startPE(peName, true);                        // REVISIT: [Q] Why do we skip spaces here? -Ac                        // REVISIT: This will make returning the non-                        //          normalized value harder. -Ac                        fEntityScanner.skipSpaces();                        if (!fEntityScanner.skipChar('%'))                            break;                    }                }                else {                    int c = fEntityScanner.peekChar();                    if (XMLChar.isHighSurrogate(c)) {                        scanSurrogates(fStringBuffer2);                    }                    else if (isInvalidLiteral(c)) {                        reportFatalError("InvalidCharInLiteral",                        new Object[]{Integer.toHexString(c)});                        fEntityScanner.scanChar();                    }                    // if it's not the delimiting quote or if it is but from a                    // different entity than the one this literal started from,                    // simply append the character to our buffer                    else if (c != quote || entityDepth != fEntityDepth) {                        fStringBuffer.append((char)c);                        fStringBuffer2.append((char)c);                        fEntityScanner.scanChar();                    }                }            } while (fEntityScanner.scanLiteral(quote, fString) != quote);            fStringBuffer.append(fString);            fStringBuffer2.append(fString);            literal = fStringBuffer;            literal2 = fStringBuffer2;        }        value.setValues(literal);        nonNormalizedValue.setValues(literal2);        if (!fEntityScanner.skipChar(quote)) {            reportFatalError("CloseQuoteMissingInDecl", null);        }    } // scanEntityValue(XMLString,XMLString):void        /**     * Scans a notation declaration     * <p>     * <pre>     * [82] NotationDecl ::= '&lt;!NOTATION' S Name S (ExternalID|PublicID) S? '>'     * [83]  PublicID    ::= 'PUBLIC' S PubidLiteral     * </pre>     * <p>     * <strong>Note:</strong> Called after scanning past '&lt;!NOTATION'     */    private final void scanNotationDecl() throws IOException, XNIException {                // spaces        fReportEntity = false;        if (!skipSeparator(true, !scanningInternalSubset())) {            reportFatalError("MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_NOTATIONDECL",            null);        }                // notation name        String name = fEntityScanner.scanName();        if (name == null) {            reportFatalError("MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL",            null);        }                // spaces        if (!skipSeparator(true, !scanningInternalSubset())) {            reportFatalError("MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL",            new Object[]{name});        }                // external id        scanExternalID(fStrings, true);        String systemId = fStrings[0];        String publicId = fStrings[1];        String baseSystemId = fEntityScanner.getBaseSystemId();                if (systemId == null && publicId == null) {            reportFatalError("ExternalIDorPublicIDRequired",            new Object[]{name});        }                // skip possible trailing space        skipSeparator(false, !scanningInternalSubset());                // end        if (!fEntityScanner.skipChar('>')) {            reportFatalError("NotationDeclUnterminated", new Object[]{name});        }        fMarkUpDepth--;                fResourceIdentifier.setValues(publicId, systemId, baseSystemId, XMLEntityManager.expandSystemId(systemId, baseSystemId ));        if (nonV

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -