1,3 → 1,7 |
/* |
* input 2072160977 bytes; AMD Athlon 3100+, disk speed 38.0 MB/s |
* 49.18s user 10.07s system 89% cpu 1:06.32 total; RES 9384K (empty java - 8200K) |
*/ |
import java.io.*; |
|
public class XmlParser |
34,6 → 38,8 |
class XmlException |
extends Exception |
{ |
static final long serialVersionUID = 1; |
|
private long line; |
private long linePos; |
|
203,7 → 209,9 |
//log("parseDecl begin " + bufPos); |
|
// begin |
if(!testChar('<', bufPos) || !testChar('?', bufPos) || !testChar('x', bufPos) || !testChar('m', bufPos) || !testChar('l', bufPos)) { |
if(!testChar('<', bufPos) || !testChar('?', bufPos) || !testChar('x', bufPos) |
|| !testChar('m', bufPos) || !testChar('l', bufPos)) |
{ |
//log("parseDecl no 'xml' " + bufPos); |
return false; |
} |
296,8 → 304,6 |
throws XmlException, IOException |
{ |
//log("parseAttribute begin " + bufPos); |
int start = bufPos; |
|
// name |
if(!parseName(selName)) { |
//log("parseAttribute no name " + bufPos); |
436,9 → 442,7 |
} |
|
XmlSelection selEndName = new XmlSelection(); |
if(!parseEndTag(selEndName)) { |
throwException("cannot find tag end"); |
} |
parseEndTag(selEndName); |
|
//if(element.name != selEndName |
// throwException("tag names do not match"); |
489,16 → 493,13 |
return true; |
} |
|
private boolean parseEndTag(XmlSelection sel) |
private void parseEndTag(XmlSelection sel) |
throws XmlException, IOException |
{ |
//log("parseEndTag begin " + bufPos); |
int start = bufPos; |
|
// begin |
if(!testChar('<', bufPos) || !testChar('/', bufPos)) { |
//log("parseEndTag no signature " + bufPos); |
return false; |
throwException("cannot find tag end"); |
} |
|
// name |
515,7 → 516,6 |
} |
|
//log("parseEndTag ok " + bufPos); |
return true; |
} |
|
private boolean parseTagContent(XmlElement element) |