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

📄 xmldtdscannerimpl.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,"EntityNotDeclared",            new Object[]{name}, XMLErrorReporter.SEVERITY_ERROR);        }        fEntityManager.startEntity(fSymbolTable.addSymbol(pName),        literal);        // if we actually got a new entity and it's external        // parse text decl if there is any        if (depth != fPEDepth && fEntityScanner.isExternal()) {            scanTextDecl();        }    }        /**     * Dispatch an XML "event".     *     * @param complete True if this method is intended to scan     *                 and dispatch as much as possible.     *     * @return True if a TextDecl was scanned.     *     * @throws IOException  Thrown on i/o error.     * @throws XNIException Thrown on parse error.     *     */    protected final boolean scanTextDecl()    throws IOException, XNIException {                // scan XMLDecl        boolean textDecl = false;        if (fEntityScanner.skipString("<?xml")) {            fMarkUpDepth++;            // NOTE: special case where document starts with a PI            //       whose name starts with "xml" (e.g. "xmlfoo")            if (isValidNameChar(fEntityScanner.peekChar())) {                fStringBuffer.clear();                fStringBuffer.append("xml");                while (isValidNameChar(fEntityScanner.peekChar())) {                    fStringBuffer.append((char)fEntityScanner.scanChar());                }                String target =                fSymbolTable.addSymbol(fStringBuffer.ch,                fStringBuffer.offset,                fStringBuffer.length);                scanPIData(target, fString);            }                        // standard Text declaration            else {                // pseudo-attribute values                String version = null;                String encoding = null;                                scanXMLDeclOrTextDecl(true, fStrings);                textDecl = true;                fMarkUpDepth--;                                version = fStrings[0];                encoding = fStrings[1];                                fEntityScanner.setEncoding(encoding);                                // call handler                if (fDTDHandler != null) {                    fDTDHandler.textDecl(version, encoding, null);                }            }        }        fEntityManager.fCurrentEntity.mayReadChunks = true;                return textDecl;            } // scanTextDecl(boolean):boolean        /**     * Scans a processing data. This is needed to handle the situation     * where a document starts with a processing instruction whose     * target name <em>starts with</em> "xml". (e.g. xmlfoo)     *     * @param target The PI target     * @param data The string to fill in with the data     */    protected final void scanPIData(String target, XMLString data)    throws IOException, XNIException {        //Venu REVISIT        //      super.scanPIData(target, data);        fMarkUpDepth--;                // call handler        if (fDTDHandler != null) {            fDTDHandler.processingInstruction(target, data, null);        }            } // scanPIData(String)        /**     * Scans a comment.     * <p>     * <pre>     * [15] Comment ::= '&lt!--' ((Char - '-') | ('-' (Char - '-')))* '-->'     * </pre>     * <p>     * <strong>Note:</strong> Called after scanning past '&lt;!--'     */    protected final void scanComment() throws IOException, XNIException {                fReportEntity = false;        scanComment(fStringBuffer);        fMarkUpDepth--;                // call handler        if (fDTDHandler != null) {            fDTDHandler.comment(fStringBuffer, null);        }        fReportEntity = true;            } // scanComment()        /**     * Scans an element declaration     * <p>     * <pre>     * [45]    elementdecl    ::=    '&lt;!ELEMENT' S Name S contentspec S? '>'     * [46]    contentspec    ::=    'EMPTY' | 'ANY' | Mixed | children     * </pre>     * <p>     * <strong>Note:</strong> Called after scanning past '&lt;!ELEMENT'     */    protected final void scanElementDecl() throws IOException, XNIException {                // spaces        fReportEntity = false;        if (!skipSeparator(true, !scanningInternalSubset())) {            reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ELEMENTDECL",            null);        }                // element name        String name = fEntityScanner.scanName();        if (name == null) {            reportFatalError("MSG_ELEMENT_TYPE_REQUIRED_IN_ELEMENTDECL",            null);        }                // spaces        if (!skipSeparator(true, !scanningInternalSubset())) {            reportFatalError("MSG_SPACE_REQUIRED_BEFORE_CONTENTSPEC_IN_ELEMENTDECL",            new Object[]{name});        }                // content model        if (fDTDContentModelHandler != null) {            fDTDContentModelHandler.startContentModel(name, null);        }        String contentModel = null;        fReportEntity = true;        if (fEntityScanner.skipString("EMPTY")) {            contentModel = "EMPTY";            // call handler            if (fDTDContentModelHandler != null) {                fDTDContentModelHandler.empty(null);            }        }        else if (fEntityScanner.skipString("ANY")) {            contentModel = "ANY";            // call handler            if (fDTDContentModelHandler != null) {                fDTDContentModelHandler.any(null);            }        }        else {            if (!fEntityScanner.skipChar('(')) {                reportFatalError("MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN",                new Object[]{name});            }            if (fDTDContentModelHandler != null) {                fDTDContentModelHandler.startGroup(null);            }            fStringBuffer.clear();            fStringBuffer.append('(');            fMarkUpDepth++;            skipSeparator(false, !scanningInternalSubset());                        // Mixed content model            if (fEntityScanner.skipString("#PCDATA")) {                scanMixed(name);            }            else {              // children content                scanChildren(name);            }            contentModel = fStringBuffer.toString();        }                // call handler        if (fDTDContentModelHandler != null) {            fDTDContentModelHandler.endContentModel(null);        }                fReportEntity = false;        skipSeparator(false, !scanningInternalSubset());        // end        if (!fEntityScanner.skipChar('>')) {            reportFatalError("ElementDeclUnterminated", new Object[]{name});        }        fReportEntity = true;        fMarkUpDepth--;                // call handler        if (fDTDHandler != null) {            fDTDHandler.elementDecl(name, contentModel, null);        }        if (nonValidatingMode) nvGrammarInfo.elementDecl(name, contentModel, null);    } // scanElementDecl()        /**     * scan Mixed content model     * This assumes the content model has been parsed up to #PCDATA and     * can simply append to fStringBuffer.     * <pre>     * [51]    Mixed    ::=    '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*'     *                       | '(' S? '#PCDATA' S? ')'     * </pre>     *     * @param elName The element type name this declaration is about.     *     * <strong>Note:</strong> Called after scanning past '(#PCDATA'.     */    private final void scanMixed(String elName)    throws IOException, XNIException {                String childName = null;                fStringBuffer.append("#PCDATA");        // call handler        if (fDTDContentModelHandler != null) {            fDTDContentModelHandler.pcdata(null);        }        skipSeparator(false, !scanningInternalSubset());        while (fEntityScanner.skipChar('|')) {            fStringBuffer.append('|');            // call handler            if (fDTDContentModelHandler != null) {                fDTDContentModelHandler.separator(XMLDTDContentModelHandler.SEPARATOR_CHOICE,                null);            }            skipSeparator(false, !scanningInternalSubset());                        childName = fEntityScanner.scanName();            if (childName == null) {                reportFatalError("MSG_ELEMENT_TYPE_REQUIRED_IN_MIXED_CONTENT",                new Object[]{elName});            }            fStringBuffer.append(childName);            // call handler            if (fDTDContentModelHandler != null) {                fDTDContentModelHandler.element(childName, null);            }            skipSeparator(false, !scanningInternalSubset());        }        // The following check must be done in a single call (as opposed to one        // for ')' and then one for '*') 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) {                fDTDContentModelHandler.endGroup(null);                fDTDContentModelHandler.occurrence(XMLDTDContentModelHandler.OCCURS_ZERO_OR_MORE,                null);            }        }        else if (childName != null) {            reportFatalError("MixedContentUnterminated",            new Object[]{elName});        }        else if (fEntityScanner.skipChar(')')){            fStringBuffer.append(')');            // call handler            if (fDTDContentModelHandler != null) {                fDTDContentModelHandler.endGroup(null);            }        }        else {            reportFatalError("MSG_CLOSE_PAREN_REQUIRED_IN_CHILDREN",            new Object[]{elName});        }        fMarkUpDepth--;        // we are done    }        /**     * scan children content model     * This assumes it can simply append to fStringBuffer.     * <pre>     * [47]    children  ::=    (choice | seq) ('?' | '*' | '+')?     * [48]    cp        ::=    (Name | choice | seq) ('?' | '*' | '+')?     * [49]    choice    ::=    '(' S? cp ( S? '|' S? cp )+ S? ')'     * [50]    seq       ::=    '(' S? cp ( S? ',' S? cp )* S? ')'     * </pre>     *     * @param elName The element type name this declaration is about.     *     * <strong>Note:</strong> Called after scanning past the first open     * paranthesis.     */    private final void scanChildren(String elName)    throws IOException, XNIException {                fContentDepth = 0;        pushContentStack(0);        int currentOp = 0;        int c;        while (true) {            if (fEntityScanner.skipChar('(')) {                fMarkUpDepth++;                fStringBuffer.append('(');                // call handler                if (fDTDContentModelHandler != null) {                    fDTDContentModelHandler.startGroup(null);                }                // push current op on stack and reset it                pushContentStack(currentOp);                currentOp = 0;                skipSeparator(false, !scanningInternalSubset());                continue;            }            skipSeparator(false, !scanningInternalSubset());            String childName = fEntityScanner.scanName();            if (childName == null) {                reportFatalError("MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN",                new Object[]{elName});                return;            }            // call handler            if (fDTDContentModelHandler != null) {                fDTDContentModelHandler.element(childName, null);            }            fStringBuffer.append(childName);            c = fEntityScanner.peekChar();            if (c == '?' || c == '*' || c == '+') {                // call handler                if (fDTDContentModelHandler != null) {                    short oc;                    if (c == '?') {                        oc = XMLDTDContentModelHandler.OCCURS_ZERO_OR_ONE;                    }                    else if (c == '*') {                        oc = XMLDTDContentModelHandler.OCCURS_ZERO_OR_MORE;                    }                    else {                        oc = XMLDTDContentModelHandler.OCCURS_ONE_OR_MORE;                    }                    fDTDContentModelHandler.occurrence(oc, null);                }                fEntityScanner.scanChar();                fStringBuffer.append((char)c);            }            while (true) {                skipSeparator(false, !scanningInternalSubset());

⌨️ 快捷键说明

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