home *** CD-ROM | disk | FTP | other *** search
Wrap
package com.ms.xml.parser; import com.ms.xml.om.Element; import com.ms.xml.om.ElementFactory; import com.ms.xml.util.Atom; import com.ms.xml.util.EnumWrapper; import com.ms.xml.util.Name; import com.ms.xml.util.XMLInputStream; import com.ms.xml.util.XMLOutputStream; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.net.URL; import java.util.Hashtable; import java.util.Vector; public class Parser { static final int TAGSTART = 60; static final int TAGEND = 62; static final int SLASH = 47; // $FF: renamed from: EQ int static final int field_0 = 61; static final int LPAREN = 40; static final int RPAREN = 41; static final int BANG = 33; static final int QMARK = 63; static final int DASH = 45; static final int PERCENT = 37; static final int AMP = 38; static final int LEFTSQB = 91; static final int RIGHTSQB = 93; static final int QUOTE = 39; // $FF: renamed from: OR int static final int field_1 = 124; static final int ASTERISK = 42; static final int PLUS = 43; static final int HASH = 35; static final int COMMA = 44; static final int INVALIDTOKEN = 0; static final int EOF = -1; static final int WHITESPACE = -2; static final int WORDCHAR = -3; static final int NAME = -4; static final int TEXT = -5; static final int PITAGSTART = -6; static final int PITAGEND = -7; static final int DECLTAGSTART = -8; static final int CLOSETAGSTART = -9; static final int EMPTYTAGEND = -10; static final int COMMENT = -11; static final int DOCTYPE = -12; static final int SYSTEM = -13; static final int CDATATAGSTART = -14; static final int ELEMENT = -15; static final int EMPTY = -16; static final int ANY = -17; static final int PCDATA = -18; static final int ATTLIST = -19; static final int CDATA = -20; // $FF: renamed from: ID int static final int field_2 = -21; static final int IDREF = -22; static final int IDREFS = -23; static final int ENTITY = -24; static final int ENTITIES = -25; static final int NMTOKEN = -26; static final int NMTOKENS = -27; static final int NOTATION = -28; static final int ENUMERATION = -29; static final int FIXED = -30; static final int REQUIRED = -31; static final int IMPLIED = -32; static final int NDATA = -33; static final int INCLUDETAGSTART = -34; static final int IGNORETAGSTART = -35; static final int NAMESPACE = -36; static final int EXTENDS = -37; static final int IMPLEMENTS = -38; static final int XML = -39; static final int VERSION = -40; static final int ENCODING = -41; static final int STANDALONE = -42; static final int CDEND = -43; static final int PUBLIC = -100; ElementFactory factory; DTD dtd; boolean validating; Element root; Vector contexts = new Vector(16); int contextAt = 0; Context current; EntityReader reader; XMLInputStream xmlIn; boolean inTag; boolean seenWS; int lookahead; char quote; char[] chars = new char[8192]; int charAt; char[] buf = new char[8192]; int bufAt; int nameappend; static Hashtable tokens; int token; int keyword; int nouppercase; int substitution; int breakText; int nametoken; int simplename; int inEntityRef; boolean expandNamedEntities; static boolean jdk11; Name name; String text; URL url; Name docType; boolean internalSubset; boolean caseInsensitive; boolean firstLine = true; static ElementDecl XMLDecl; Name conditionRef; boolean standAlone; boolean loadexternal; static int[] chartype = new int[256]; static char[] charupper = new char[256]; static final int FWHITESPACE = 1; static final int FDIGIT = 2; static final int FLETTER = 4; static final int FMISCNAME = 8; static final int FSTARTNAME = 16; static final char nameSpaceSeparator = ':'; static boolean strict = false; boolean shortendtags; static Name nameComment = Name.create("--"); static Name nameCDATA = Name.create("[CDATA["); static Name namePCDATA = Name.create("PCDATA"); static Name nameVERSION = Name.create("version"); static Name nameENCODING = Name.create("encoding"); static Name nameDOCTYPE = Name.create("DOCTYPE"); static Name nameXML = Name.create("xml"); static Name nameStandalone = Name.create("standalone"); static Name nameYes = Name.create("yes"); static Name nameNo = Name.create("no"); static Name nameURL = Name.create("URL"); static Name namePUBLICID = Name.create("PUBLICID"); static Name nameNAME = Name.create("NAME"); static Name nameXMLSpace = Name.create("xml-space", "xml"); static Name nameXMLSpace2 = Name.create("space", "xml"); static Name nameXMLAS = Name.create("prefix", "xml"); static Name nameXMLHREF = Name.create("src", "xml"); static Name nameXMLNS = Name.create("ns", "xml"); static Name nameXMLNameSpace = Name.create("namespace", "xml"); static Atom atomXML = Atom.create("xml"); static Name nameXMLLang = Name.create("lang", "xml"); final String scanUrl() throws ParseException { this.parseToken(39, "Url"); this.scanString(this.quote, 65535, 65535, 65535); return this.text; } final void parseAttributes(Element var1) throws ParseException { boolean var2 = false; while(this.nextToken() == -4) { Name var3 = this.name; if (var3.getName().equals(nameXMLSpace.getName())) { var3 = nameXMLSpace; var2 = true; } if (var1 != null && var1.getAttribute(var3) != null) { this.error("An attribute cannot appear more than once in the same start tag"); } this.parseToken(61, "="); if (var3 == nameXMLLang) { this.parseToken(39, "string"); this.parseToken(-4, "lang code"); Name var4 = this.name; this.parseToken(39, "string"); this.factory.parsedAttribute(var1, var3, var4.getName()); } else if (this.current.ed != null && var1 != null) { this.current.ed.parseAttribute(var1, var3, this); } else { this.parseToken(39, "string"); this.scanString(this.quote, 38, 38, 60); this.factory.parsedAttribute(var1, var3, this.text); } } if (var2) { Object var5 = var1.getAttribute(nameXMLSpace); if (var5 == null) { var5 = var1.getAttribute(nameXMLSpace2); } if (var5 != null) { String var6 = null; if (var5 instanceof String) { var6 = (String)var5; } else if (var5 instanceof Atom) { var6 = var5.toString(); } else if (var5 instanceof Name) { var6 = ((Name)var5).getName().toString(); } if (var6 != null && var6.equalsIgnoreCase("preserve")) { this.current.preserveWS = true; } else if (var6 != null && var6.equalsIgnoreCase("default")) { this.current.preserveWS = false; } else { this.error("Invalid value '" + var6 + "' for xml-space attribute."); } } } if (this.current.ed != null) { this.current.ed.checkAttributes(var1, this); } } public final void parse(URL var1, ElementFactory var2, DTD var3, Element var4, boolean var5, boolean var6) throws ParseException { this.dtd = var3; this.root = var4; this.loadexternal = var6; this.setURL(var1); this.setFactory(var2); this.caseInsensitive = var5; this.safeParse(); } public final void parse(InputStream var1, ElementFactory var2, DTD var3, Element var4, boolean var5, boolean var6) throws ParseException { this.dtd = var3; this.url = null; this.root = var4; this.loadexternal = var6; this.setInputStream(var1); this.setFactory(var2); this.caseInsensitive = var5; this.safeParse(); } final ElementDecl createElementDecl(Vector var1) throws ParseException { if (this.token != -4) { this.error("Expected " + this.tokenString(-4) + " instead of " + this.tokenString(this.token)); } if (this.dtd.findElementDecl(this.name) != null) { this.error("Element '" + this.name + "' already declared."); } ElementDecl var2 = new ElementDecl(this.name); this.current.lastWasWS = false; this.dtd.addElementDecl(var2); var1.addElement(var2); return var2; } final Element parseNameSpaceDecl(boolean var1, boolean var2) throws ParseException { Element var3 = this.addNewElement(10, this.name, false, (String)null); this.push(var3, this.name, 10); this.parseAttributes(var3); this.pop(); if (var2 && this.token != -7) { this.error("Expected PI tag end '?>' instead of " + this.tokenString(this.token)); } else if (!var2 && this.token != -10) { this.error("Expected " + this.tokenString(-10) + " instead of " + this.tokenString(this.token)); } Object var4 = var3.getAttribute(nameXMLAS); Object var5 = var3.getAttribute(nameXMLHREF); Object var6 = var3.getAttribute(nameXMLNS); if (var4 == null || var6 == null) { this.error("Missing attribute 'ns' or 'prefix'"); } Atom var9 = null; Atom var7; Atom var8; if (this.caseInsensitive) { var7 = Atom.create(var4.toString().toUpperCase()); var8 = Atom.create(var6.toString().toUpperCase()); if (var5 != null) { var9 = Atom.create(var9.toString().toUpperCase()); } } else { var7 = Atom.create(var4.toString()); var8 = Atom.create(var6.toString()); if (var5 != null) { var9 = Atom.create(var9.toString()); } } if (DTD.isReservedNameSpace(var7)) { this.error(var7.toString() + " is a reserved name space."); } this.addNameSpace(var7, var8, var1); if (this.loadexternal && var9 != null && this.dtd.findLoadedNameSpace(var9) == null) { this.dtd.addLoadedNameSpace(var9); this.loadDTD(var9.toString(), var9); } return var3; } public void setShortEndTags(boolean var1) { this.shortendtags = var1; } public final XMLOutputStream createOutputStream(OutputStream var1) { return this.xmlIn != null ? this.xmlIn.createOutputStream(var1) : null; } final Element finishPI() throws ParseException { Element var1 = this.addNewElement(5, this.name, false, (String)null); this.charAt = 0; boolean var2 = false; while(this.lookahead != -1) { this.chars[this.charAt++] = (char)this.lookahead; if (this.lookahead == 63) { this.advance(); if (this.lookahead == 62) { this.charAt += -1; var2 = true; } } else { this.advance(); } if (this.charAt == this.chars.length || var2) { this.push(var1, this.name, 5); this.addNewElement(6, (Name)null, false, new String(this.chars, 0, this.charAt)); this.pop(); this.charAt = 0; if (var2) { break; } } } this.parseToken(62, "PI end"); return var1; } static final boolean isNameChar(char var0) { if (var0 < 256) { return (chartype[var0] & 14) != 0; } else { return Character.isLetter(var0) || Character.isDigit(var0) || var0 == '-' || var0 == '_' || var0 == '.'; } } final void addChar() throws ParseException { if (this.lookahead == -1) { this.error("Unexpected EOF."); } this.chars[this.charAt++] = (char)this.lookahead; if (this.charAt == this.chars.length) { this.addNewElement(1, (Name)null, true, new String(this.chars, 0, this.charAt)); this.charAt = 0; } this.advance(); } final char toUpperCase(char var1) { if (this.nouppercase != 0) { return var1; } else { return var1 < 256 ? charupper[var1] : Character.toUpperCase(var1); } } final void scanCharRef() throws ParseException { int var1 = 0; if (this.lookahead == 35) { this.advance(); if (this.lookahead != 120 && this.lookahead != 88) { while(this.lookahead >= 48 && this.lookahead <= 57) { var1 = var1 * 10 + this.lookahead - 48; this.advance(); } } else { this.advance(); while(true) { if (this.lookahead >= 48 && this.lookahead <= 57) { var1 = var1 * 16 + this.lookahead - 48; } else if (this.lookahead >= 97 && this.lookahead <= 102) { var1 = var1 * 16 + this.lookahead - 97 + 10; } else { if (this.lookahead < 65 || this.lookahead > 70) { break; } var1 = var1 * 16 + this.lookahead - 65 + 10; } this.advance(); } } } if (this.lookahead != 59) { this.error("Bad character reference syntax. Expecting x;"); } else { this.chars[this.charAt++] = (char)var1; } this.advance(); } private final void setFactory(ElementFactory var1) { this.factory = var1; } final void scanText(int var1, int var2, boolean var3) throws ParseException { this.charAt = 0; while(this.lookahead != -1 && this.lookahead != 60 && this.lookahead != this.breakText && this.charAt + 1 < this.chars.length) { if (this.lookahead == var2) { if (this.seenWS) { this.chars[this.charAt++] = ' '; this.seenWS = false; } this.advance(); if (this.lookahead == 35) { this.scanCharRef(); } else if (isNameChar((char)this.lookahead)) { this.scanEntityRef(false); } else { this.chars[this.charAt++] = (char)var2; } } else if (this.lookahead == var1) { if (this.seenWS) { this.chars[this.charAt++] = ' '; this.seenWS = false; } this.advance(); if (isNameChar((char)this.lookahead)) { this.scanEntityRef(var1 == 37); } else { this.chars[this.charAt++] = (char)var2; } } else { if (var3 && isWhiteSpaceChar((char)this.lookahead)) { this.seenWS = true; } else { if (this.seenWS) { this.chars[this.charAt++] = ' '; this.seenWS = false; } this.chars[this.charAt++] = (char)this.lookahead; } this.advance(); } } this.token = -5; } final void tryMisc() throws ParseException { while(true) { switch (this.token) { case -11: this.parseComment(); break; case -10: case -9: case -8: case -7: default: return; case -6: this.parsePI(true); } if (this.lookahead == -1) { this.token = -1; return; } this.nextToken(); this.firstLine = false; } } final String tokenString(int var1) { return this.tokenString(var1, (String)null); } final String tokenString(int var1, String var2) { switch (var1) { case -100: return "PUBLIC"; case -43: return "]]>"; case -36: return "NAMESPACE"; case -35: return "IGNORETAGSTART"; case -34: return "INCLUDETAGSTART"; case -33: return "NDATA"; case -32: return "IMPLIED"; case -31: return "REQUIRED"; case -30: return "FIXED"; case -29: return "ENUMERATION"; case -28: return "NOTATION"; case -27: return "NMTOKENS"; case -26: return "NMTOKEN"; case -25: return "ENTITIES"; case -24: return "ENTITY"; case -23: return "IDREFS"; case -22: return "IDREF"; case -21: return "ID"; case -20: return "CDATA"; case -19: return "ATTLIST"; case -18: return "PCDATA"; case -17: return "ANY"; case -16: return "EMPTY"; case -15: return "ELEMENT"; case -14: return "<![CDATA"; case -13: return "SYSTEM"; case -12: return "DOCTYPE"; case -11: return "<!--"; case -10: return "/>"; case -9: return "</"; case -8: return "<!"; case -7: return "?>"; case -6: return "<?"; case -5: return "TEXT '" + this.text + "'"; case -4: if (var2 != null) { return var2; } return "NAME '" + this.name + "'"; case -3: return "word character"; case -2: return "whitespace"; case -1: return "EOF"; case 0: return "invalidtoken"; case 33: return "!"; case 35: return "#"; case 37: return "percent(%)"; case 38: return "&"; case 39: return "quote(' or \")"; case 40: return "("; case 41: return ")"; case 42: return "*"; case 43: return "+"; case 44: return ","; case 45: return "-"; case 47: return "/"; case 60: return "start tag(<)"; case 61: return "="; case 62: return "tag end(>)"; case 63: return "question mark(?)"; case 91: return "["; case 93: return "]"; case 124: return "|"; default: return var2; } } public final void loadDTD(String var1, Atom var2) throws ParseException { try { URL var3 = new URL(this.url, var1); Parser var4 = new Parser(); var4.dtd = this.dtd; var4.setURL(var3); var4.setFactory(this.factory); var4.caseInsensitive = this.caseInsensitive; var4.loadexternal = this.loadexternal; Element var5 = this.factory.createElement((Element)null, 0, nameDOCTYPE, (String)null); var4.newContext(var5, (Name)null, 0, false, var2, this.current.spaceTable); var4.parseInternalSubset(); this.validating = true; } catch (IOException var6) { this.error("Couldn't find external DTD '" + var1 + "'"); } } private void reportMismatch(int var1, String var2) throws ParseException { if (this.current.ed == null) { this.error("Content mismatch. Stopped at state " + var1); } Vector var3 = this.current.ed.expectedElements(var1); this.error(var2 + " Expected elements " + var3); } final int scanSimpleName(int var1, String var2) throws ParseException { boolean var3; if (this.lookahead < 256) { var3 = (chartype[this.lookahead] & 20) != 0; } else { var3 = Character.isLetter((char)this.lookahead) || this.lookahead == 95; } if (!var3 && (this.nametoken <= 0 || !Character.isDigit((char)this.lookahead))) { this.error("Expecting " + var2 + " instead of '" + (char)this.lookahead + "'"); } if (this.nametoken == 0 && this.simplename == 0) { if (this.caseInsensitive) { this.buf[var1++] = this.toUpperCase((char)this.lookahead); this.advance(); while(isNameChar((char)this.lookahead)) { this.buf[var1++] = this.toUpperCase((char)this.lookahead); this.advance(); } } else { this.buf[var1++] = (char)this.lookahead; this.advance(); while(isNameChar((char)this.lookahead)) { this.buf[var1++] = (char)this.lookahead; this.advance(); } } } else if (this.caseInsensitive) { this.buf[var1++] = this.toUpperCase((char)this.lookahead); this.advance(); while(isNameChar((char)this.lookahead) || this.lookahead == 58) { this.buf[var1++] = this.toUpperCase((char)this.lookahead); this.advance(); } } else { this.buf[var1++] = (char)this.lookahead; this.advance(); while(isNameChar((char)this.lookahead) || this.lookahead == 58) { this.buf[var1++] = (char)this.lookahead; this.advance(); } } return var1; } final void parseEntityDecl() throws ParseException { boolean var1 = false; ++this.nouppercase; if (this.nextToken() == 37) { var1 = true; this.parseToken(-4, "Entity name"); } else if (this.token != -4) { this.error("Expected entity name instead of " + this.tokenString(this.token)); } this.nouppercase += -1; Entity var2 = this.dtd.findEntity(this.name); if (var2 != null) { System.err.println("Warning: Entity '" + this.name + "' already defined, using the first definition."); var2 = new Entity(this.name, var1); } else { var2 = new Entity(this.name, var1); this.dtd.addEntity(var2); if (this.internalSubset) { if (this.current.e != null) { this.current.e.addChild(var2, (Element)null); } this.current.lastWasWS = false; } } this.push(var2, this.name, 7); this.parseKeyword(0, "String or SYSTEM"); if (this.token == -100) { this.parseKeyword(0, "String"); if (this.token == 39) { this.expandNamedEntities = false; this.scanString(this.quote, 65535, 65535, 65535); this.expandNamedEntities = true; var2.pubid = this.text; this.token = -13; } else { this.error("Expected " + this.tokenString(39) + " instead of " + this.tokenString(this.token)); } } switch (this.token) { case -13: var2.setURL(this.scanUrl()); this.parseKeyword(0, "ndata"); if (this.token == -33) { this.parseToken(-4, "ndata name"); Notation var6 = this.dtd.findNotation(this.name); if (var6 == null) { this.error("Notation: " + this.name + " has not been declared yet"); } var2.setNDATA(this.name); this.nextToken(); } break; case 39: int var3 = this.reader.line; int var4 = this.reader.column; this.expandNamedEntities = false; this.scanString(this.quote, 37, 38, 65535); this.expandNamedEntities = true; var2.setText(this.text); var2.setPosition(var3, var4); this.nextToken(); break; default: this.error("Expected " + this.tokenString(39) + " or " + this.tokenString(-13) + " instead of " + this.tokenString(this.token)); } this.checkToken(62, ">"); this.pop(); } final void checkToken(int var1, String var2) throws ParseException { if (this.token != var1) { this.error("Expected " + this.tokenString(var1, var2) + " instead of " + this.tokenString(this.token)); } } final void tryDocTypeDecl() throws ParseException { if (this.token == -8) { this.firstLine = false; this.parseKeyword(-12, "Doctype"); Element var1 = this.addNewElement(4, nameDOCTYPE, false, (String)null); this.parseToken(-4, "Doctype name"); this.docType = this.name; this.dtd.docType = this.name; this.factory.parsedAttribute(var1, nameNAME, this.docType); this.parseKeyword(0, "ExternalID"); String var2 = null; switch (this.token) { case -100: this.parseKeyword(0, "String"); if (this.token == 39) { this.expandNamedEntities = false; this.scanString(this.quote, 65535, 65535, 65535); this.expandNamedEntities = true; this.factory.parsedAttribute(var1, namePUBLICID, this.text); } else { this.error("Expected " + this.tokenString(39) + " instead of " + this.tokenString(this.token)); } var2 = this.scanUrl(); this.factory.parsedAttribute(var1, nameURL, var2); this.nextToken(); break; case -13: var2 = this.scanUrl(); this.factory.parsedAttribute(var1, nameURL, var2); this.nextToken(); } if (this.token == 91) { this.inTag = false; this.breakText = 93; this.internalSubset = true; this.push(var1, nameDOCTYPE, 4); this.parseInternalSubset(); if (this.token != 93) { this.error("Expected " + this.tokenString(93)); } this.inTag = true; this.internalSubset = false; this.breakText = 0; this.pop(); this.nextToken(); } if (var2 != null && this.loadexternal) { this.loadDTD(var2.toString(), (Atom)null); } if (this.token != 62) { this.error("Expected " + this.tokenString(62) + " instead of " + this.tokenString(this.token)); } if (this.lookahead != -1) { this.nextToken(); } } } final void parseElementDecl() throws ParseException { Vector var1 = new Vector(); this.nextToken(); ElementDecl var2 = this.createElementDecl(var1); if (this.internalSubset && this.current.e != null) { this.current.e.addChild(var2, (Element)null); } this.push(var2, this.name, 9); var2.parseModel(this); this.checkToken(62, ">"); this.pop(); } final void parseNotation() throws ParseException { this.parseToken(-4, "Notation name"); Notation var1 = this.dtd.findNotation(this.name); if (var1 != null) { this.error("Notation already declared " + this.name); } var1 = new Notation(this.name); this.dtd.addNotation(var1); if (this.internalSubset) { if (this.current.e != null) { this.current.e.addChild(var1, (Element)null); } this.current.lastWasWS = false; } this.push(var1, this.name, 8); this.parseKeyword(0, "SYSTEM or PUBLIC"); if (this.token != -13 && this.token != -100) { this.error("Expected " + this.tokenString(-13) + " or " + this.tokenString(-100) + " instead of " + this.tokenString(this.token)); } var1.type = this.token; if (var1.type == -100) { this.parseKeyword(0, "String"); if (this.token == 39) { this.expandNamedEntities = false; this.scanString(this.quote, 65535, 65535, 65535); this.expandNamedEntities = true; var1.pubid = this.text; } else { this.error("Expected " + this.tokenString(39) + " instead of " + this.tokenString(this.token)); } } var1.setURL(this.scanUrl()); this.parseToken(62, ">"); this.pop(); } final void parseToken(int var1, String var2) throws ParseException { if (this.nextToken() != var1) { this.error("Expected " + this.tokenString(var1, var2) + " instead of " + this.tokenString(this.token)); } } final Element addNewElement(int var1, Name var2, boolean var3, String var4) throws ParseException { if (var1 == 12) { this.current.lastWasWS = true; } else { this.current.lastWasWS = false; } Element var5 = this.factory.createElement(this.current.e, var1, var2, var4); if (var3 && var5 != null) { Context var6 = this.current; if (this.current.parent != null) { var6 = this.current.parent; } if (var6.ed != null) { var6.ed.checkContent(var6, var5, this); } } return var5; } final void parseElement() throws ParseException { boolean var1 = false; while(true) { if (var1 && this.token != -9) { this.error("Expected " + this.tokenString(-9) + " instead of " + this.tokenString(this.token)); } var1 = false; switch (this.token) { case -14: this.parseCDATA(); break; case -11: this.parseComment(); break; case -9: if (!this.current.matched) { this.reportMismatch(this.current.state, this.current.e.getTagName().getName() + " is not complete."); } if (!this.shortendtags || this.lookahead != 62) { if (this.lookahead == 47) { this.advance(); } else { Context var4 = this.current; this.current = (Context)this.contexts.elementAt(this.contextAt - 1); this.scanName("element close tag"); this.current = var4; if (this.name != this.current.tagName) { this.error("Close tag " + this.name + " does not match start tag " + this.current.e.getTagName()); } } } this.parseToken(62, ">"); this.factory.parsed(this.current.e); this.pop(); break; case -6: this.parsePI(false); break; case -5: this.parseText(38, 38); break; case -1: if (this.contextAt == 1) { this.error("Expected the end of root element instead of end of file."); break; } default: this.error("Bad token in element content: " + this.tokenString(this.token)); break; case 60: this.scanName("element tag"); ElementDecl var2 = null; Element var3 = this.addNewElement(0, this.name, true, (String)null); this.push(var3, this.name, 0); if (this.validating) { var2 = this.dtd.findElementDecl(this.name); if (var2 != null) { if (var2.getContent().type == 1) { var1 = true; } var2.initContent(this.current, this); } else { this.error("Element '" + this.name + "' used but not declared in the DTD."); } } else { this.current.matched = true; } this.parseAttributes(var3); if (this.token == -10) { if (var2 != null && !var2.acceptEmpty(this.current)) { this.reportMismatch(0, var2.name.getName() + " cannot be empty."); } this.factory.parsed(this.current.e); this.pop(); var1 = false; } else if (this.token != 62) { this.error("Expected " + this.tokenString(62) + " instead of " + this.tokenString(this.token)); } else if (this.lookahead != 60 && var1) { this.error("Expected " + this.tokenString(62) + " instead of '" + (char)this.lookahead + "'"); } } if (this.contextAt == 0) { return; } this.nextToken(); } } final void parseRootElement() throws ParseException { if (this.token != 60) { this.error("Start of root element expected instead of " + this.tokenString(this.token)); } this.scanName("element tag"); if (this.docType != null && this.name != this.docType) { this.error("Root element name must match the DOCTYPE name"); } if (this.name == nameXMLNameSpace) { this.parseNameSpaceDecl(false, false); } else { ElementDecl var1 = null; Element var2 = this.addNewElement(0, this.name, false, (String)null); this.push(var2, this.name, 0); boolean var3 = false; if (this.validating) { var1 = this.dtd.findElementDecl(this.name); if (var1 != null) { if (var1.getContent().type == 1) { var3 = true; } var1.initContent(this.current, this); } else { this.error("Element '" + this.name + "' used but not declared in the DTD."); } } else { this.current.matched = true; } this.parseAttributes(var2); if (this.token == -10) { if (var1 != null && !var1.acceptEmpty(this.current)) { this.reportMismatch(0, "Root element " + var2.getTagName().getName() + " cannot be empty."); } var3 = true; } else if (this.token != 62) { if (var2.getAttributes() == EnumWrapper.emptyEnumeration) { this.error("No attribute is declared for element '" + var2.getTagName() + "', expected " + this.tokenString(62)); } this.error("Expected " + this.tokenString(62) + " instead of " + this.tokenString(this.token)); } if (var3) { this.pop(); this.nextToken(); } else { this.nextToken(); this.parseElement(); } } } final void parseContent(Element var1) throws ParseException { while(this.nextToken() != -9) { switch (this.token) { case -14: this.parseCDATA(); break; case -11: this.parseComment(); break; case -8: this.parseElement(); break; case -6: this.parsePI(false); break; case -5: this.parseText(38, 38); break; case 60: this.parseElement(); break; default: this.error("Bad token in element content: " + this.tokenString(this.token)); } } if (!this.current.matched) { this.error("Content mismatch, stopped at state " + this.current.state); } if (this.lookahead != 62) { this.scanName("element close tag"); if (this.name != this.current.e.getTagName()) { this.error("Close tag mismatch: " + this.name + " instead of " + this.current.e.getTagName()); } } this.parseToken(62, ">"); } final void error(String var1) throws ParseException { int var2 = 1; if (this.token == -4) { var2 = this.name.toString().length(); } throw new ParseException(var1, this.reader.line, this.reader.column - 1 - var2, this.reader.owner); } static final boolean isWhiteSpaceChar(char var0) { if (var0 < 256) { return (chartype[var0] & 1) != 0; } else { return jdk11 ? Character.isWhitespace(var0) : Character.isSpace(var0); } } final void parseDocument() throws ParseException { this.expandNamedEntities = true; this.internalSubset = false; this.seenWS = false; this.contextAt = 0; this.standAlone = false; this.validating = false; this.newContext(this.root, (Name)null, 0, false, (Atom)null, (Hashtable)null); this.parseProlog(); this.parseRootElement(); if (this.lookahead != -1) { this.nextToken(); this.tryMisc(); if (this.lookahead != -1) { this.error("Expected comments, PI, or EOF instead of " + this.tokenString(this.token)); } } this.dtd.checkIDs(); } final void parseIgnoreSectContent() throws ParseException { boolean var1 = false; while(this.lookahead != 93) { switch (this.lookahead) { case 34: case 39: int var2 = this.lookahead; this.addChar(); while(this.lookahead != var2) { this.checkCDEND(false); this.addChar(); } this.addChar(); break; case 60: this.addChar(); switch (this.lookahead) { case 33: this.addChar(); switch (this.lookahead) { case 45: this.addChar(); if (this.lookahead != 45) { this.error("Bad comment syntax. Expected '-'."); } this.addChar(); while(!var1) { if (this.lookahead == 45) { this.addChar(); if (this.lookahead == 45) { this.addChar(); if (this.lookahead == 62) { this.addChar(); var1 = true; } else { this.error("Bad comment syntax. Expected '>'."); } } } else { this.addChar(); } } var1 = false; continue; case 91: this.addChar(); this.parseIgnoreSectContent(); continue; default: this.addChar(); continue; } case 63: this.addChar(); while(!var1) { if (this.lookahead == 63) { this.addChar(); if (this.lookahead == 62) { this.addChar(); var1 = true; } } else { this.addChar(); } } var1 = false; continue; default: this.error("Bad character in IGNORE conditional section."); continue; } default: this.addChar(); } } this.checkCDEND(true); } private final void setInputStream(InputStream var1) throws ParseException { this.xmlIn = new XMLInputStream(var1); this.reader = new EntityReader(this.xmlIn, 1, 1, (EntityReader)null, this); this.advance(); } public final void report(ParseException var1, OutputStream var2) { PrintStream var3 = new PrintStream(var2); String var4 = null; var3.println(((Throwable)var1).getMessage()); if (var1.owner instanceof Parser) { URL var5 = ((Parser)var1.owner).url; if (var5 != null) { var4 = var5.toString(); } } else if (var1.owner instanceof Entity) { var4 = "Parsing <" + ((Entity)var1.owner).name + ">"; } else { var4 = "Parsing"; } var3.println("Location: " + var4 + "(" + var1.line + "," + var1.column + ")"); var3.print("Context: "); for(int var7 = 0; var7 < this.contextAt; ++var7) { Name var6 = ((Context)this.contexts.elementAt(var7)).e.getTagName(); if (var6 != null) { var3.print("<" + var6 + ">"); } } var3.print("<"); if (this.current != null) { var3.print(this.current.e.getTagName()); } var3.println(">"); } void newContext(Element var1, Name var2, int var3, boolean var4, Atom var5, Hashtable var6) { if (this.contextAt == this.contexts.size()) { this.current = new Context(var1, var2, var3, var4, var5, var6); this.contexts.addElement(this.current); } else { this.current = (Context)this.contexts.elementAt(this.contextAt); this.current.reset(var1, var2, var3, var4, var5, var6); } } final int parseNames(Vector var1, int var2, StringBuffer var3) throws ParseException { int var4 = 0; this.bufAt = 0; if (var3 != null) { ++this.nameappend; } while(this.nextToken() == -4) { if (var4 > 0) { this.buf[this.bufAt++] = ' '; } var1.addElement(this.name); ++var4; if (var2 != 0 && this.nextToken() != 124) { break; } } if (var3 != null) { var3.append(this.buf, 0, this.bufAt); this.nameappend += -1; } return var4; } final void advance() throws ParseException { for(this.lookahead = this.reader.read(); this.lookahead == -1 && this.reader.owner != this; this.lookahead = this.reader.read()) { if (this.charAt != 0) { this.addPCDATA(); } this.reader = this.reader.prev; this.pop(); if (!this.inTag) { this.charAt = 0; } } } private void addNameSpace(Atom var1, Atom var2, boolean var3) throws ParseException { if (var1 == null || var2 == null) { this.error("Name space syntax error."); } if (DTD.isReservedNameSpace(var1)) { this.error(var1.toString() + " is a reserved name space."); } if (var3) { Atom var4 = this.dtd.findShortNameSpace(var2); if (var4 == null) { var4 = this.dtd.findLongNameSpace(var1); if (var4 != null) { this.error("Short reference '" + var1.toString() + "' is used by name space '" + var4.toString() + "'"); } this.dtd.addNameSpace(var1, var2); return; } if (var4 != var1) { this.error("Cannot give two short references '" + var4.toString() + "' and '" + var1.toString() + "' to the same name space: '" + var2.toString() + "'"); return; } } else { this.current.addNameSpace(var1, var2); } } final void safeParse() throws ParseException { try { this.parseDocument(); } catch (ParseException var4) { if (this.xmlIn != null) { try { this.xmlIn.close(); } catch (Exception var2) { } } throw var4; } try { this.xmlIn.close(); } catch (Exception var3) { } } final Element addPCDATA() throws ParseException { if (this.charAt <= 0 && !this.seenWS) { this.seenWS = false; return null; } else { if (this.seenWS) { this.chars[this.charAt++] = ' '; this.seenWS = false; } this.text = new String(this.chars, 0, this.charAt); Element var1 = this.addNewElement(1, (Name)null, true, this.text); return var1; } } final void parseXMLDecl() throws ParseException { Element var1 = this.addNewElement(5, this.name, false, (String)null); this.push(var1, this.name, 5); ElementDecl var2 = this.current.ed; this.current.ed = XMLDecl; this.parseKeyword(-40, nameVERSION.toString()); this.parseToken(61, "="); this.parseToken(39, "string"); this.scanString(this.quote, 65535, 65535, 65535); if (!this.text.equals("1.0")) { this.error("Expected version 1.0 instead of " + this.text); } this.factory.parsedAttribute(var1, nameVERSION, this.text); this.parseKeyword(0, "encoding or standalone"); String var3 = null; if (this.token == -41) { this.parseToken(61, "="); this.parseToken(39, "string"); this.scanString(this.quote, 65535, 65535, 65535); this.factory.parsedAttribute(var1, nameENCODING, this.text); var3 = this.text; this.parseKeyword(0, nameStandalone.toString()); } if (this.token == -42) { this.parseToken(61, "="); this.parseToken(39, "string"); this.scanString(this.quote, 65535, 65535, 65535); if (this.caseInsensitive) { this.text = this.text.toUpperCase(); } Name var4 = Name.create(this.text); if (var4 == nameYes) { this.standAlone = true; } else if (var4 == nameNo) { this.standAlone = false; } else { this.error("Expected 'yes' or 'no' instead of " + var4); } this.factory.parsedAttribute(var1, nameStandalone, var4.toString()); this.nextToken(); } if (var3 != null) { try { this.xmlIn.setEncoding(var3); } catch (IOException var5) { this.error("Unsupported XML encoding: \"" + var3 + "\"" + "\nLow level error: " + ((Throwable)var5).getMessage()); } } if (this.token != -7) { this.error("Expected " + this.tokenString(-7) + " instead of " + this.tokenString(this.token)); } this.current.ed = var2; this.pop(); } final void parseProlog() throws ParseException { if (this.lookahead != -1) { this.nextToken(); if (this.token == -6) { this.parseToken(-4, "PI tag"); if (this.name == nameXML) { this.parseXMLDecl(); } else if (this.name == nameXMLNameSpace) { this.parseNameSpaceDecl(true, true); } else { this.finishPI(); } this.nextToken(); this.firstLine = false; } } this.tryMisc(); this.tryDocTypeDecl(); this.tryMisc(); } final ElementDecl findElementDecl(Vector var1) throws ParseException { if (this.token != -4) { this.error("Expected " + this.tokenString(-4) + " instead of " + this.tokenString(this.token)); } ElementDecl var2 = this.dtd.findElementDecl(this.name); if (var2 == null) { this.error("Missing Element declaration '" + this.name + "'"); } var1.addElement(var2); return var2; } final void parseAttListDecl() throws ParseException { Vector var1 = new Vector(); this.nextToken(); ElementDecl var2 = this.findElementDecl(var1); this.push(var2, this.name, 9); var2.parseAttList(this); this.checkToken(62, ">"); this.pop(); } final void parseCDATA() throws ParseException { this.charAt = 0; boolean var1 = false; while(this.lookahead != -1) { this.chars[this.charAt++] = (char)this.lookahead; if (this.lookahead == 93) { this.advance(); if (this.lookahead == 93) { this.advance(); if (this.lookahead == 62) { this.charAt += -1; var1 = true; } else { this.reader.push((char)this.lookahead); this.lookahead = 93; } } } else { this.advance(); } if (this.charAt == this.chars.length || var1) { this.addNewElement(6, nameCDATA, false, new String(this.chars, 0, this.charAt)); this.charAt = 0; if (var1) { break; } } } this.parseToken(62, "CDATA end"); } final void checkCDEND(boolean var1) throws ParseException { boolean var2 = false; if (this.lookahead == 93) { this.addChar(); if (this.lookahead == 93) { this.addChar(); if (this.lookahead == 62) { if (!var1) { this.error("Bad Ignore conditional section syntex. ']]>' is not allowed here."); } var2 = true; this.addChar(); } } } if (!var2 && var1) { this.error("Bad Ignore conditional section syntex. Expected ']]>'."); } } final void pop() { this.current = (Context)this.contexts.elementAt(this.contextAt += -1); } final void parseIncludeSection() throws ParseException { Element var1 = this.addNewElement(13, this.conditionRef, false, (String)null); this.push(var1, this.conditionRef, 13); this.parseInternalSubset(); this.pop(); } final void parseIgnoreSection() throws ParseException { Element var1 = this.addNewElement(14, this.conditionRef, false, (String)null); this.charAt = 0; this.push(var1, this.conditionRef, 14); this.parseIgnoreSectContent(); if (this.charAt > 0) { this.addNewElement(1, (Name)null, true, new String(this.chars, 0, this.charAt)); this.charAt = 0; } this.pop(); } final int nextToken() throws ParseException { this.bufAt = 0; int var1 = this.bufAt; if (this.inTag || !this.current.preserveWS) { for(; isWhiteSpaceChar((char)this.lookahead); this.advance()) { if (!this.inTag) { this.buf[this.bufAt++] = (char)this.lookahead; this.seenWS = true; } } } if (this.inTag) { switch (this.lookahead) { case -1: this.token = -1; break; case 34: case 39: this.quote = (char)this.lookahead; this.token = 39; this.advance(); break; case 35: case 40: case 41: case 42: case 43: case 44: case 61: case 91: case 93: case 124: this.token = this.lookahead; this.advance(); break; case 37: this.advance(); if (this.substitution > 0 && isNameChar((char)this.lookahead)) { this.scanEntityRef(true); return this.nextToken(); } this.token = 37; break; case 47: this.advance(); if (this.lookahead == 62) { this.token = -10; this.inTag = false; this.advance(); } break; case 62: this.token = 62; this.inTag = false; this.advance(); break; case 63: this.advance(); if (this.current.type == 9) { this.token = 63; } else if (this.lookahead == 62) { this.token = -7; this.inTag = false; this.advance(); } else { this.token = 63; } break; default: if (!isNameChar((char)this.lookahead) && ':' != (char)this.lookahead) { this.error("Unexpected token '" + (char)this.lookahead + "' inside tag <" + this.current.e.getTagName() + ">"); } else { this.scanName("name"); if (this.keyword > 0) { this.token = this.lookup(this.name.getName()); } } } } else { if (this.seenWS && !this.current.lastWasWS && (this.lookahead == -1 || this.lookahead == 60)) { this.addNewElement(12, (Name)null, false, new String(this.buf, var1, this.bufAt - var1)); } switch (this.lookahead) { case -1: this.token = -1; break; case 60: this.inTag = true; this.seenWS = false; this.advance(); switch (this.lookahead) { case 33: this.token = -8; this.advance(); if (this.lookahead == 45) { this.advance(); if (this.lookahead == 45) { this.token = -11; this.advance(); } else { this.error("Bad comment start syntax. Expected '<!--'"); } return this.token; } else { if (this.lookahead == 91) { this.advance(); boolean var2 = false; if (this.lookahead == 37) { this.advance(); Entity var3 = this.scanEntityRef(true); this.conditionRef = var3.getName(); var2 = true; } else { this.conditionRef = null; } this.parseKeyword(0, "CDATA or Conditional section start tag"); if (this.token == -34 || this.token == -35 || this.token == -20 && !var2) { if (this.token == -20) { this.token = -14; } else { this.inTag = false; } if (this.lookahead == 91) { this.advance(); return this.token; } else { if (this.token == -14) { this.error("Bad CDATA start syntax. Expected '['"); } else { this.error("Bad conditional section start syntax. Expected '['"); } return this.token; } } else { this.error("Bad start tag: '<!['" + this.tokenString(this.token) + this.token); return this.token; } } return this.token; } case 47: this.token = -9; this.advance(); return this.token; case 63: this.token = -6; this.advance(); return this.token; default: this.token = 60; return this.token; } case 93: this.advance(); if (this.lookahead == 93) { this.advance(); if (this.lookahead == 62) { this.advance(); this.token = -43; break; } this.reader.push((char)this.lookahead); this.reader.push(']'); this.lookahead = 93; } else { this.reader.push((char)this.lookahead); this.lookahead = 93; } if (this.breakText == this.lookahead) { this.advance(); this.token = 93; break; } default: this.token = -5; } } return this.token; } final void parseInternalSubset() throws ParseException { ++this.substitution; this.validating = true; while(true) { switch (this.nextToken()) { case -35: this.parseIgnoreSection(); break; case -34: this.parseIncludeSection(); break; case -11: this.parseComment(); break; case -8: this.parseKeyword(0, "ENTITY|..."); switch (this.token) { case -28: this.parseNotation(); continue; case -24: this.parseEntityDecl(); continue; case -19: this.parseAttListDecl(); continue; case -15: this.parseElementDecl(); continue; default: this.error("Unknown DTD keyword " + this.name); continue; } case -6: this.parsePI(true); break; case -5: if (this.lookahead != 37) { this.error("Unexpected text in DTD."); return; } this.advance(); this.scanEntityRef(true); break; case 93: if (!this.internalSubset) { System.out.println("Illegal token in DTD: " + this.token); } case -1: this.substitution += -1; return; default: return; } } } public Parser() { jdk11 = true; this.caseInsensitive = false; this.shortendtags = false; } final Element parseComment() throws ParseException { Element var1 = this.addNewElement(2, nameComment, false, (String)null); this.charAt = 0; boolean var2 = false; while(this.lookahead != -1) { this.chars[this.charAt++] = (char)this.lookahead; if (this.lookahead == 45) { this.advance(); if (this.lookahead == 45) { this.advance(); if (this.lookahead == 62) { this.charAt += -1; var2 = true; } else if (strict) { this.error("Bad comment syntax. Expected '>'."); } else { this.reader.push((char)this.lookahead); this.lookahead = 45; } } } else { this.advance(); } if (this.charAt == this.chars.length || var2) { this.push(var1, nameComment, 2); this.addNewElement(6, (Name)null, false, new String(this.chars, 0, this.charAt)); this.pop(); this.charAt = 0; if (var2) { break; } } } this.parseToken(62, "comment end"); return var1; } final void parseKeyword(int var1, String var2) throws ParseException { ++this.keyword; if (var1 == 0) { this.nextToken(); } else { this.parseToken(var1, var2); } this.keyword += -1; } final void push(Element var1, Name var2, int var3) { ++this.contextAt; this.newContext(var1, var2, var3, this.current.preserveWS, this.current.nameSpace, this.current.spaceTable); } final void scanString(int var1, int var2, int var3, int var4) throws ParseException { this.charAt = 0; while(this.lookahead != -1 && this.lookahead != var1) { if (this.lookahead == var4) { this.error("Illegal character in string " + (char)this.lookahead); } else if (this.lookahead == var3) { this.advance(); if (this.lookahead == 35) { this.scanCharRef(); } else if (isNameChar((char)this.lookahead)) { if (this.expandNamedEntities) { this.scanEntityRef(false); } else { this.chars[this.charAt++] = (char)var3; } } else { this.chars[this.charAt++] = (char)this.lookahead; } } else if (this.lookahead == var2) { this.advance(); if (isNameChar((char)this.lookahead)) { boolean var5 = var2 == 37; if (this.expandNamedEntities) { this.scanEntityRef(var5); } else { this.chars[this.charAt++] = (char)var2; } } else { this.chars[this.charAt++] = (char)this.lookahead; } } else { this.chars[this.charAt++] = (char)this.lookahead; this.advance(); } } if (this.lookahead == var1) { this.advance(); } else { this.error("Unterminated string"); } this.text = new String(this.chars, 0, this.charAt); } static { XMLDecl = new ElementDecl(nameXML); XMLDecl.addAttDef(new AttDef(nameVERSION, 0, "1.0", 3)); XMLDecl.addAttDef(new AttDef(nameENCODING, 0, "UTF-8", 2)); Vector var0 = new Vector(2); var0.addElement(nameYes); var0.addElement(nameNo); XMLDecl.addAttDef(new AttDef(nameStandalone, 9, (Name)var0.elementAt(0), 2, var0)); tokens = new Hashtable(); tokens.put("DOCTYPE", new Integer(-12)); tokens.put("SYSTEM", new Integer(-13)); tokens.put("PUBLIC", new Integer(-100)); tokens.put("ENTITY", new Integer(-24)); tokens.put("ELEMENT", new Integer(-15)); tokens.put("EMPTY", new Integer(-16)); tokens.put("ANY", new Integer(-17)); tokens.put("PCDATA", new Integer(-18)); tokens.put("ATTLIST", new Integer(-19)); tokens.put("CDATA", new Integer(-20)); tokens.put("ID", new Integer(-21)); tokens.put("IDREF", new Integer(-22)); tokens.put("IDREFS", new Integer(-23)); tokens.put("ENTITY", new Integer(-24)); tokens.put("ENTITIES", new Integer(-25)); tokens.put("NMTOKEN", new Integer(-26)); tokens.put("NMTOKENS", new Integer(-27)); tokens.put("FIXED", new Integer(-30)); tokens.put("REQUIRED", new Integer(-31)); tokens.put("IMPLIED", new Integer(-32)); tokens.put("NDATA", new Integer(-33)); tokens.put("NOTATION", new Integer(-28)); tokens.put("INCLUDE", new Integer(-34)); tokens.put("IGNORE", new Integer(-35)); tokens.put("namespace", new Integer(-36)); tokens.put("EXTENDS", new Integer(-37)); tokens.put("IMPLEMENTS", new Integer(-38)); tokens.put("xml", new Integer(-39)); tokens.put("version", new Integer(-40)); tokens.put("encoding", new Integer(-41)); tokens.put("standalone", new Integer(-42)); int var1 = 0; do { char var2 = (char)var1; chartype[var1] = 0; if (jdk11 && Character.isWhitespace(var2) || Character.isSpace(var2) || var2 == '\r') { chartype[var1] = 1; } if (Character.isLetter(var2)) { int[] var10000 = chartype; var10000[var1] |= 4; } if (Character.isDigit(var2)) { int[] var3 = chartype; var3[var1] |= 2; } charupper[var1] = Character.toUpperCase(var2); ++var1; } while(var1 < 256); int[] var4 = chartype; var4[46] |= 8; var4 = chartype; var4[45] |= 8; var4 = chartype; var4[95] |= 24; var4 = chartype; var4[183] |= 8; } final Entity scanEntityRef(boolean var1) throws ParseException { ++this.nouppercase; ++this.inEntityRef; this.scanName("entity ref"); this.inEntityRef += -1; this.nouppercase += -1; if (this.lookahead != 59) { this.error("Entity reference syntax error " + this.name); } Entity var2 = this.dtd.findEntity(this.name); if (var2 == null) { String var3 = "Missing entity '" + this.name + "'."; if (!this.loadexternal) { var3 = var3 + "\nPerhaps you need to change the loadexternal flag to 'true'."; } this.error(var3); } if (var1 != var2.par) { if (var1) { this.error("Entity '" + this.name + "' is not a parameter entity."); } else { this.error("Entity '" + this.name + "' is a parameter entity."); } } if (var1) { if (!this.inTag) { this.addNewElement(11, this.name, false, (String)null); } if (var2.getURL() == null) { this.push(var2, this.name, 7); this.reader = var2.getReader(this.reader); } else { if (var2.ndata != null) { this.error("Binary parameter entity " + this.name.toString() + "cannot be used in DTD"); } if (this.loadexternal) { this.loadDTD(var2.getURL(), this.current.defaultNameSpace); } } } else { if (!this.inTag) { this.addPCDATA(); this.charAt = 0; this.addNewElement(11, this.name, true, (String)null); } if (var2.getLength() != -1 && !var2.parsed) { Context var6 = this.current; if (var6.parent != null) { var6 = var6.parent; } if (var2.getURL() == null) { var2.parsed = true; this.push(var2, this.name, 7); this.current.parent = var6; this.reader = var2.getReader(this.reader); } else if (var2.ndata == null && this.loadexternal) { var2.parsed = true; this.push(var2, this.name, 7); this.current.parent = var6; try { URL var4 = new URL(this.url, var2.getURL()); this.reader = new EntityReader(var4.openStream(), this.reader.line, this.reader.column, this.reader, var2); } catch (Exception var5) { this.error("Cannot load external text entity: " + this.name.toString()); } } } } this.advance(); return var2; } final Element parsePI(boolean var1) throws ParseException { this.parseKeyword(0, "PI name"); if (this.token == -39) { if (this.firstLine) { this.parseXMLDecl(); return null; } this.error("An XML declaration can only appear in the very beginning of the document."); } else { if (this.token == -36) { return this.parseNameSpaceDecl(var1, true); } if (this.token != -4) { this.error("Expecting PI name instead of " + this.tokenString(this.token)); } } return this.finishPI(); } final Element parseText(int var1, int var2) throws ParseException { this.scanText(var1, var2, !this.current.preserveWS); return this.addPCDATA(); } private final void setURL(URL var1) throws ParseException { this.url = var1; try { this.setInputStream(new BufferedInputStream(this.url.openStream())); } catch (IOException var3) { throw new ParseException("Error opening input stream for \"" + this.url.toString() + "\": " + ((Throwable)var3).toString()); } } final int lookup(String var1) { Object var2 = tokens.get(var1); if (var2 != null) { this.token = (Integer)var2; } else { this.token = -4; } return this.token; } final void scanName(String var1) throws ParseException { Object var2 = null; Atom var3 = null; boolean var4 = false; if (this.nameappend == 0) { this.bufAt = 0; } int var5 = this.bufAt; if (':' != (char)this.lookahead) { this.bufAt = this.scanSimpleName(this.bufAt, var1); var4 = true; } if (this.nametoken == 0 && this.simplename == 0 && ':' == (char)this.lookahead) { int var6 = 1; ++this.bufAt; this.advance(); if (':' == (char)this.lookahead) { ++var6; ++this.bufAt; this.advance(); } if (var4) { String var8; if (this.caseInsensitive) { var8 = (new String(this.buf, var5, this.bufAt - var5 - var6)).toUpperCase(); } else { var8 = new String(this.buf, var5, this.bufAt - var5 - var6); } Atom var7 = Atom.create(var8); if (DTD.isReservedNameSpace(var7)) { var3 = var7; } else { var3 = this.current.findNameSpace(var7); if (var3 == null) { var3 = this.dtd.findLongNameSpace(var7); if (var3 == null) { var3 = var7; this.addNameSpace(var7, var7, false); } } } } var5 = this.bufAt; this.bufAt = this.scanSimpleName(this.bufAt, var1); } else if (this.nametoken == 0 && this.simplename == 0 || this.inEntityRef > 0) { var3 = this.current.defaultNameSpace; } if (this.nametoken == 0 && this.simplename == 0 || this.inEntityRef > 0) { this.current.nameSpace = var3; } if ((this.keyword <= 0 || this.inEntityRef != 0) && var3 != null) { this.name = Name.create(new String(this.buf, var5, this.bufAt - var5), var3); } else { this.name = Name.create(this.buf, var5, this.bufAt - var5); } this.token = -4; } }