String wrong = checkKeyword(c, XmlConsts.XML_DECL_KW_VERSION);
if (wrong != null) {
throwParseError(ErrorConsts.ERR_UNEXP_KEYWORD, wrong, XmlConsts.XML_DECL_KW_VERSION);
}
c = skipEquals(XmlConsts.XML_DECL_KW_VERSION, SUFFIX_IN_XML_DECL);
TextBuffer tb = mTextBuffer;
tb.resetInitialized();
parseQuoted(XmlConsts.XML_DECL_KW_VERSION, c, tb);
if (tb.equalsString(XmlConsts.XML_V_10_STR)) {
mDocXmlVersion = XmlConsts.XML_V_10;
mXml11 = false;
} else if (tb.equalsString(XmlConsts.XML_V_11_STR)) {
mDocXmlVersion = XmlConsts.XML_V_11;
mXml11 = true;
} else {
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+"'");
}
c = getNextInCurrAfterWS(SUFFIX_IN_XML_DECL);
if (c != '?') { // '?' signals end...
if (c == 'e') { // encoding
wrong = checkKeyword(c, XmlConsts.XML_DECL_KW_ENCODING);
if (wrong != null) {
throwParseError(ErrorConsts.ERR_UNEXP_KEYWORD, wrong, XmlConsts.XML_DECL_KW_ENCODING);
}
c = skipEquals(XmlConsts.XML_DECL_KW_ENCODING, SUFFIX_IN_XML_DECL);
tb.resetWithEmpty();
parseQuoted(XmlConsts.XML_DECL_KW_ENCODING, c, tb);
mDocXmlEncoding = tb.toString();
/* should we verify encoding at this point? let's not, for now;
* since it's for information only, first declaration from
* bootstrapper is used for the whole stream.
*/
c = getNextInCurrAfterWS(SUFFIX_IN_XML_DECL);
} else if (c != 's') {
throwUnexpectedChar(c, " in xml declaration; expected either 'encoding' or 'standalone' pseudo-attribute");
}
// Standalone?
if (c == 's') {
wrong = checkKeyword(c, XmlConsts.XML_DECL_KW_STANDALONE);
if (wrong != null) {
throwParseError(ErrorConsts.ERR_UNEXP_KEYWORD, wrong, XmlConsts.XML_DECL_KW_STANDALONE);
}
c = skipEquals(XmlConsts.XML_DECL_KW_STANDALONE, SUFFIX_IN_XML_DECL);
tb.resetWithEmpty();
parseQuoted(XmlConsts.XML_DECL_KW_STANDALONE, c, tb);
if (tb.equalsString(XmlConsts.XML_SA_YES)) {
mDocStandalone = DOC_STANDALONE_YES;
} else if (tb.equalsString(XmlConsts.XML_SA_NO)) {
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+"'");
}
c = getNextInCurrAfterWS(SUFFIX_IN_XML_DECL);
}
}