private class XMLHelper extends XML {
Vector obStack = new Vector();
- public void startElement(String name, String[] keys, Object[] vals, int line, int col) throws SAXException {
+ public XMLHelper() { super(BUFFER_SIZE); }
+
+ public void startElement(XML.Element c) throws XML.SchemaException {
JSObject o = new JSObject();
- o.put("$name", null, name);
- for(int i=0; i<keys.length; i++) o.put(keys[i], null, vals[i]);
+ o.put("$name", null, c.localName);
+ for(int i=0; i<c.len; i++) o.put(c.keys[i], null, c.vals[i]);
o.put("$numchildren", null, new Integer(0));
obStack.addElement(o);
}
- public void endElement(String name, int line, int col) throws SAXException {
+ public void endElement(XML.Element c) throws XML.SchemaException {
if (obStack.size() == 1) return;
JSObject me = (JSObject)obStack.lastElement();
obStack.setSize(obStack.size() - 1);
parent.put(numchildren, null, me);
}
- public void content(char[] content, int start, int length, int line, int col) throws SAXException {
- String s = new String(content, start, length);
+ public void characters(char[] ch, int start, int length) throws XML.SchemaException {
+ String s = new String(ch, start, length);
JSObject parent = (JSObject)obStack.lastElement();
int numchildren = ((Integer)parent.get("$numchildren", null)).intValue();
Object lastChild = parent.get(numchildren - 1, null);
}
}
+ public void whitespace(char[] ch, int start, int length) {}
+
public Scriptable doParse() throws JavaScriptException {
try {
InputStream is = getInputStream();
BufferedReader r = new BufferedReader(new InputStreamReader(is));
parse(r);
- } catch (XML.SAXException e) {
+ } catch (XML.XMLException e) {
throw new JavaScriptException("error parsing XML: " + e.toString());
} catch (IOException e) {
if (Log.on) Log.log(ByteStream.class, "IO Exception while reading from file");