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

📄 xmldtdscannerimpl.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                c = fEntityScanner.peekChar();                if (c == ',' && currentOp != '|') {                    currentOp = c;                    // call handler                    if (fDTDContentModelHandler != null) {                        fDTDContentModelHandler.separator(XMLDTDContentModelHandler.SEPARATOR_SEQUENCE,                        null);                    }                    fEntityScanner.scanChar();                    fStringBuffer.append(',');                    break;                }                else if (c == '|' && currentOp != ',') {                    currentOp = c;                    // call handler                    if (fDTDContentModelHandler != null) {                        fDTDContentModelHandler.separator(XMLDTDContentModelHandler.SEPARATOR_CHOICE,                        null);                    }                    fEntityScanner.scanChar();                    fStringBuffer.append('|');                    break;                }                else if (c != ')') {                    reportFatalError("MSG_CLOSE_PAREN_REQUIRED_IN_CHILDREN",                    new Object[]{elName});                }                // call handler                if (fDTDContentModelHandler != null) {                    fDTDContentModelHandler.endGroup(null);                }                // restore previous op                currentOp = popContentStack();                short oc;                // The following checks must be done in a single call (as                // opposed to one for ')' and then one for '?', '*', and '+')                // to guarantee that callbacks are properly nested. We do not                // want to trigger endEntity too early in case we cross the                // boundary of an entity between the two characters.                if (fEntityScanner.skipString(")?")) {                    fStringBuffer.append(")?");                    // call handler                    if (fDTDContentModelHandler != null) {                        oc = XMLDTDContentModelHandler.OCCURS_ZERO_OR_ONE;                        fDTDContentModelHandler.occurrence(oc, null);                    }                }                else if (fEntityScanner.skipString(")+")) {                    fStringBuffer.append(")+");                    // call handler                    if (fDTDContentModelHandler != null) {                        oc = XMLDTDContentModelHandler.OCCURS_ONE_OR_MORE;                        fDTDContentModelHandler.occurrence(oc, null);                    }                }                else if (fEntityScanner.skipString(")*")) {                    fStringBuffer.append(")*");                    // call handler                    if (fDTDContentModelHandler != null) {                        oc = XMLDTDContentModelHandler.OCCURS_ZERO_OR_MORE;                        fDTDContentModelHandler.occurrence(oc, null);                    }                }                else {                    // no occurrence specified                    fEntityScanner.scanChar();                    fStringBuffer.append(')');                }                fMarkUpDepth--;                if (fContentDepth == 0) {                    return;                }            }            skipSeparator(false, !scanningInternalSubset());        }    }        /**     * Scans an attlist declaration     * <p>     * <pre>     * [52]  AttlistDecl    ::=   '&lt;!ATTLIST' S Name AttDef* S? '>'     * [53]  AttDef         ::=   S Name S AttType S DefaultDecl     * </pre>     * <p>     * <strong>Note:</strong> Called after scanning past '&lt;!ATTLIST'     */    protected final void scanAttlistDecl() throws IOException, XNIException {                // spaces        fReportEntity = false;        if (!skipSeparator(true, !scanningInternalSubset())) {            reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ATTLISTDECL",            null);        }                // element name        String elName = fEntityScanner.scanName();        if (elName == null) {            reportFatalError("MSG_ELEMENT_TYPE_REQUIRED_IN_ATTLISTDECL",            null);        }                // call handler        if (fDTDHandler != null) {            fDTDHandler.startAttlist(elName, null);        }                // spaces        if (!skipSeparator(true, !scanningInternalSubset())) {            // no space, is it the end yet?            if (fEntityScanner.skipChar('>')) {                // yes, stop here                // call handler                if (fDTDHandler != null) {                    fDTDHandler.endAttlist(null);                }                fMarkUpDepth--;                return;            }            else {                reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ATTRIBUTE_NAME_IN_ATTDEF",                new Object[]{elName});            }        }                // definitions        while (!fEntityScanner.skipChar('>')) {            String name = fEntityScanner.scanName();            if (name == null) {                reportFatalError("AttNameRequiredInAttDef",                new Object[]{elName});            }            // spaces            if (!skipSeparator(true, !scanningInternalSubset())) {                reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ATTTYPE_IN_ATTDEF",                new Object[]{elName, name});            }            // type            String type = scanAttType(elName, name);                        // spaces            if (!skipSeparator(true, !scanningInternalSubset())) {                reportFatalError("MSG_SPACE_REQUIRED_BEFORE_DEFAULTDECL_IN_ATTDEF",                new Object[]{elName, name});            }                        // default decl            String defaultType = scanAttDefaultDecl(elName, name,            type,            fLiteral, fLiteral2);            // REVISIT: Should we do anything with the non-normalized            //          default attribute value? -Ac            // yes--according to bug 5073.  - neilg            String[] enumr = null;            if( fDTDHandler != null || nonValidatingMode){                if (fEnumerationCount != 0) {                    enumr = new String[fEnumerationCount];                    System.arraycopy(fEnumeration, 0, enumr,                    0, fEnumerationCount);                }            }            // call handler            // Determine whether the default value to be passed should be null.            // REVISIT: should probably check whether fLiteral.ch is null instead. LM.            if (defaultType!=null && (defaultType.equals("#REQUIRED") ||            defaultType.equals("#IMPLIED"))) {                if (fDTDHandler != null){                    fDTDHandler.attributeDecl(elName, name, type, enumr,                    defaultType, null, null, null);                }                if(nonValidatingMode){                    nvGrammarInfo.attributeDecl(elName, name, type, enumr,                    defaultType, null, null, null);                                    }            }            else {                if (fDTDHandler != null){                    fDTDHandler.attributeDecl(elName, name, type, enumr,                    defaultType, fLiteral, fLiteral2, null);                }                if(nonValidatingMode){                    nvGrammarInfo.attributeDecl(elName, name, type, enumr,                    defaultType, fLiteral, fLiteral2, null);                }            }            skipSeparator(false, !scanningInternalSubset());        }                // call handler        if (fDTDHandler != null) {            fDTDHandler.endAttlist(null);        }        fMarkUpDepth--;        fReportEntity = true;            } // scanAttlistDecl()        /**     * Scans an attribute type definition     * <p>     * <pre>     * [54]  AttType        ::=   StringType | TokenizedType | EnumeratedType     * [55]  StringType     ::=   'CDATA'     * [56]  TokenizedType  ::=   'ID'     *                          | 'IDREF'     *                          | 'IDREFS'     *                          | 'ENTITY'     *                          | 'ENTITIES'     *                          | 'NMTOKEN'     *                          | 'NMTOKENS'     * [57]  EnumeratedType ::=    NotationType | Enumeration     * [58]  NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'     * [59]  Enumeration    ::=    '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'     * </pre>     * <p>     * <strong>Note:</strong> Called after scanning past '&lt;!ATTLIST'     *     * @param elName The element type name this declaration is about.     * @param atName The attribute name this declaration is about.     */    private final String scanAttType(String elName, String atName)    throws IOException, XNIException {                String type = null;        fEnumerationCount = 0;        /*         * Watchout: the order here is important: when a string happens to         * be a substring of another string, the longer one needs to be         * looked for first!!         */        if (fEntityScanner.skipString("CDATA")) {            type = "CDATA";        }        else if (fEntityScanner.skipString("IDREFS")) {            type = "IDREFS";        }        else if (fEntityScanner.skipString("IDREF")) {            type = "IDREF";        }        else if (fEntityScanner.skipString("ID")) {            type = "ID";        }        else if (fEntityScanner.skipString("ENTITY")) {            type = "ENTITY";        }        else if (fEntityScanner.skipString("ENTITIES")) {            type = "ENTITIES";        }        else if (fEntityScanner.skipString("NMTOKENS")) {            type = "NMTOKENS";        }        else if (fEntityScanner.skipString("NMTOKEN")) {            type = "NMTOKEN";        }        else if (fEntityScanner.skipString("NOTATION")) {            type = "NOTATION";            // spaces            if (!skipSeparator(true, !scanningInternalSubset())) {                reportFatalError("MSG_SPACE_REQUIRED_AFTER_NOTATION_IN_NOTATIONTYPE",                new Object[]{elName, atName});            }            // open paren            int c = fEntityScanner.scanChar();            if (c != '(') {                reportFatalError("MSG_OPEN_PAREN_REQUIRED_IN_NOTATIONTYPE",                new Object[]{elName, atName});            }            fMarkUpDepth++;            do {                skipSeparator(false, !scanningInternalSubset());                String aName = fEntityScanner.scanName();                if (aName == null) {                    reportFatalError("MSG_NAME_REQUIRED_IN_NOTATIONTYPE",                    new Object[]{elName, atName});                }                ensureEnumerationSize(fEnumerationCount + 1);                fEnumeration[fEnumerationCount++] = aName;                skipSeparator(false, !scanningInternalSubset());                c = fEntityScanner.scanChar();            } while (c == '|');            if (c != ')') {                reportFatalError("NotationTypeUnterminated",                new Object[]{elName, atName});            }            fMarkUpDepth--;        }        else {              // Enumeration            type = "ENUMERATION";            // open paren            int c = fEntityScanner.scanChar();            if (c != '(') {                //                       "OPEN_PAREN_REQUIRED_BEFORE_ENUMERATION_IN_ATTRDECL",                reportFatalError("AttTypeRequiredInAttDef",                new Object[]{elName, atName});            }            fMarkUpDepth++;            do {                skipSeparator(false, !scanningInternalSubset());                String token = fEntityScanner.scanNmtoken();                if (token == null) {                    reportFatalError("MSG_NMTOKEN_REQUIRED_IN_ENUMERATION",                    new Object[]{elName, atName});                }                ensureEnumerationSize(fEnumerationCount + 1);                fEnumeration[fEnumerationCount++] = token;                skipSeparator(false, !scanningInternalSubset());                c = fEntityScanner.scanChar();            } while (c == '|');            if (c != ')') {                reportFatalError("EnumerationUnterminated",                new Object[]{elName, atName});            }            fMarkUpDepth--;        }        return type;            } // scanAttType():String            /**     * Scans an attribute default declaration     * <p>     * <pre>     * [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)     * </pre>     *     * @param name The name of the attribute being scanned.     * @param defaultVal The string to fill in with the default value.     */    protected final String scanAttDefaultDecl(String elName, String atName,    String type,    XMLString defaultVal,    XMLString nonNormalizedDefaultVal)    throws IOException, XNIException {                String defaultType = null;        fString.clear();        defaultVal.clear();        if (fEntityScanner.skipString("#REQUIRED")) {            defaultType = "#REQUIRED";        }        else if (fEntityScanner.skipString("#IMPLIED")) {            defaultType = "#IMPLIED";        }        else {            if (fEntityScanner.skipString("#FIXED")) {                defaultType = "#FIXED";                // spaces                if (!skipSeparator(true, !scanningInternalSubset())) {                    reportFatalError("MSG_SPACE_REQUIRED_AFTER_FIXED_IN_DEFAULTDECL",                    new Object[]{elName, atName});                }            }            // AttValue            boolean isVC = !fStandalone  &&  (fSeenExternalDTD || fSeenExternalPE) ;            scanAttributeValue(defaultVal, nonNormalizedDefaultVal, atName,            fAttributes, 0, isVC);

⌨️ 快捷键说明

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