protected void handleUndeclaredEntity(String id) throws XMLStreamException { throwParseError(((mDocStandalone == DOC_STANDALONE_YES) ? ErrorConsts.ERR_WF_GE_UNDECLARED_SA : ErrorConsts.ERR_WF_GE_UNDECLARED), id, null); }
/** * Stub method implemented by validating parsers, to report content * that's not valid for current element context. Defined at this * level since some such problems need to be caught at low-level; * however, details of error reports are not needed here. */ protected void reportInvalidContent(int evtType) throws XMLStreamException { // should never happen; sub-class has to override: throwParseError("Internal error: sub-class should override method"); } }
private void reportWrongEndPrefix(String prefix, String localName, int done) throws XMLStreamException { --mInputPtr; // pushback String fullName = prefix + ":" + localName; String rest = parseFNameForError(); String actName = fullName.substring(0, done) + rest; throwParseError("Unexpected close tag </"+actName+">; expected </" +fullName+">."); }
private void reportExtraEndElem() throws XMLStreamException { String name = parseFNameForError(); throwParseError("Unbalanced close tag </"+name+">; no open start tag."); }
private void reportWrongEndElem(String prefix, String localName, int done) throws XMLStreamException { --mInputPtr; // pushback String fullName; if (prefix != null && prefix.length() > 0) { fullName = prefix + ":" + localName; done += 1 + prefix.length(); } else { fullName = localName; } String rest = parseFNameForError(); String actName = fullName.substring(0, done) + rest; throwParseError("Unexpected close tag </"+actName+">; expected </" +fullName+">."); }
throwParseError("Expected type "+tokenTypeDesc(type) +", current type " +tokenTypeDesc(curr)); if (curr != START_ELEMENT && curr != END_ELEMENT && curr != ENTITY_REFERENCE) { throwParseError("Expected non-null local name, but current token not a START_ELEMENT, END_ELEMENT or ENTITY_REFERENCE (was "+tokenTypeDesc(mCurrToken)+")"); throwParseError("Expected local name '"+localName+"'; current local name '"+n+"'."); throwParseError("Expected non-null NS URI, but current token not a START_ELEMENT or END_ELEMENT (was "+tokenTypeDesc(curr)+")"); throwParseError("Expected empty namespace, instead have '"+uri+"'."); throwParseError("Expected namespace '"+nsUri+"'; have '" +uri+"'.");
protected EntityDecl findEntity(String id, Object arg) throws XMLStreamException { EntityDecl ed = (EntityDecl) mConfig.findCustomInternalEntity(id); if (ed == null && mGeneralEntities != null) { ed = (EntityDecl) mGeneralEntities.get(id); } /* 05-Mar-2006, TSa: Externally declared entities are illegal * if we were declared as "standalone='yes'"... */ if (mDocStandalone == DOC_STANDALONE_YES) { if (ed != null && ed.wasDeclaredExternally()) { throwParseError(ErrorConsts.ERR_WF_ENTITY_EXT_DECLARED, ed.getName(), null); } } return ed; }
/** * Method called if a root-level element is found after the main * root element was closed. This is legal in multi-doc parsing * mode (and in fragment mode), but not in the default single-doc * mode. * * @return Token to return */ private int handleExtraRoot(char c) throws XMLStreamException { if (!mConfig.inputParsingModeDocuments()) { /* Has to be single-doc mode, since fragment mode * should never get here (since fragment mode never has epilog * or prolog modes) */ throwParseError("Illegal to have multiple roots (start tag in epilog?)."); } // Need to push back the char, since it is the first char of elem name --mInputPtr; return handleMultiDocStart(START_ELEMENT); }
protected void handleIncompleteEntityProblem(WstxInputSource closing) throws XMLStreamException { String top = mElementStack.isEmpty() ? "[ROOT]" : mElementStack.getTopElementDesc(); throwParseError("Unexpected end of entity expansion for entity &{0}; was expecting a close tag for element <{1}>", closing.getEntityId(), top); }
/** * This problem gets reported if an entity tries to expand to * a close tag matching start tag that did not came from the same * entity (but from parent). */ protected void handleGreedyEntityProblem(WstxInputSource input) throws XMLStreamException { String top = mElementStack.isEmpty() ? "[ROOT]" : mElementStack.getTopElementDesc(); throwParseError("Improper GE/element nesting: entity &" +input.getEntityId()+" contains closing tag for <"+top+">"); }
continue; throwParseError("Received non-all-whitespace CHARACTERS or CDATA event in nextTag()."); break; // never gets here, but jikes complains without case START_ELEMENT: return next; throwParseError("Received event "+ErrorConsts.tokenTypeDesc(next) +", instead of START_ELEMENT or END_ELEMENT.");
protected void checkCData() throws XMLStreamException { String wrong = checkKeyword(getNextCharFromCurrent(SUFFIX_IN_CDATA), "CDATA"); if (wrong != null) { throwParseError("Unrecognized XML directive '"+wrong+"'; expected 'CDATA'."); } // Plus, need the bracket too: char c = getNextCharFromCurrent(SUFFIX_IN_CDATA); if (c != '[') { throwUnexpectedChar(c, "excepted '[' after '<![CDATA'"); } // Cool, that's it! }
String keyw = checkKeyword('D', "DOCTYPE"); if (keyw != null) { throwParseError("Unrecognized XML directive '<!"+keyw+"' (misspelled DOCTYPE?)."); throwParseError(ErrorConsts.ERR_DTD_IN_EPILOG); throwParseError(ErrorConsts.ERR_DTD_DUP);
/** *<p> * Note: According to StAX 1.0, coalesced text events are always to be * returned as CHARACTERS, never as CDATA. And since at this point we * don't really know if there's anything to coalesce (but there may * be), let's convert CDATA if necessary. */ private int nextFromTreeCommentOrCData() throws XMLStreamException { char c = getNextCharFromCurrent(SUFFIX_IN_DOC); if (c == '[') { checkCData(); /* Good enough; it is a CDATA section... but let's just also * parse the easy ("free") stuff: */ c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : getNextCharFromCurrent(SUFFIX_IN_CDATA); readCDataPrimary(c); // sets token state appropriately... return CDATA; } if (c == '-' && getNextCharFromCurrent(SUFFIX_IN_DOC) == '-') { mTokenState = TOKEN_STARTED; return COMMENT; } throwParseError("Unrecognized XML directive; expected CDATA or comment ('<![CDATA[' or '<!--')."); return 0; // never gets here, but compilers don't know it... }
throwParseError(ErrorConsts.ERR_WF_PI_MISSING_TARGET); throwParseError(ErrorConsts.ERR_WF_PI_XML_TARGET, target, null);
String wrong = checkKeyword(c, XmlConsts.XML_DECL_KW_VERSION); if (wrong != null) { throwParseError(ErrorConsts.ERR_UNEXP_KEYWORD, wrong, XmlConsts.XML_DECL_KW_VERSION); mDocXmlVersion = XmlConsts.XML_V_UNKNOWN; mXml11 = false; throwParseError("Unexpected xml version '"+tb.toString()+"'; expected '"+XmlConsts.XML_V_10_STR+"' or '"+XmlConsts.XML_V_11_STR+"'"); wrong = checkKeyword(c, XmlConsts.XML_DECL_KW_ENCODING); if (wrong != null) { throwParseError(ErrorConsts.ERR_UNEXP_KEYWORD, wrong, XmlConsts.XML_DECL_KW_ENCODING); wrong = checkKeyword(c, XmlConsts.XML_DECL_KW_STANDALONE); if (wrong != null) { throwParseError(ErrorConsts.ERR_UNEXP_KEYWORD, wrong, XmlConsts.XML_DECL_KW_STANDALONE); mDocStandalone = DOC_STANDALONE_NO; } else { throwParseError("Unexpected xml '"+XmlConsts.XML_DECL_KW_STANDALONE+"' pseudo-attribute value '" +tb.toString()+"'; expected '"+XmlConsts.XML_SA_YES+"' or '"+ XmlConsts.XML_SA_NO+"'");
throwParseError("String '--' not allowed in comment (missing '>'?)");
throwParseError("String '--' not allowed in comment (missing '>'?)");
return false; } else if (c == '<') { throwParseError("Unexpected '<' character in element (missing closing '>'?)");
throwParseError(ErrorConsts.ERR_HYPHENS_IN_COMMENT);