X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Fnext%2FParser.java;h=ffbaf8879bdd96420512f7c3f7ac4e679d2de332;hb=6e40b32ee7b4e65f600f6aeb25838d6d40e76838;hp=dd0371092fbac38b6df6a57acd47e97e1e85a584;hpb=7c0e72ac740a2d9a3579977e53d935da849344f2;p=jsvc.git diff --git a/src/dolda/jsvc/next/Parser.java b/src/dolda/jsvc/next/Parser.java index dd03710..ffbaf88 100644 --- a/src/dolda/jsvc/next/Parser.java +++ b/src/dolda/jsvc/next/Parser.java @@ -3,26 +3,10 @@ package dolda.jsvc.next; import java.io.*; import java.util.*; import org.w3c.dom.*; -import org.w3c.dom.bootstrap.*; public class Parser { - private static final DOMImplementation domimp; - - static { - DOMImplementationRegistry reg; - try { - reg = DOMImplementationRegistry.newInstance(); - } catch(Exception e) { - throw(new Error(e)); - } - DOMImplementation di = reg.getDOMImplementation(""); - if(di == null) - throw(new RuntimeException("Could not get a DOM implemenation")); - domimp = di; - } - public class State { - public final Document doc = domimp.createDocument(null, "dummy", null); + public final Document doc = DomUtil.document(null, "dummy"); public final PeekReader in; private State(Reader in) { @@ -52,16 +36,6 @@ public class Parser { return(doc.createElementNS(null, name)); } - protected Attr makeattr(Document doc, Element el, String name, String val) { - Attr a = doc.createAttributeNS(el.getNamespaceURI(), name); - a.setValue(val); - return(a); - } - - protected Attr makeattr(Document doc, Element el, String name) { - return(doc.createAttributeNS(el.getNamespaceURI(), name)); - } - protected String name(State s) throws IOException { StringBuilder buf = new StringBuilder(); while(true) { @@ -91,7 +65,7 @@ public class Parser { } protected Attr attribute(State s, Element el) throws IOException { - String nm = name(s); + Attr a = s.doc.createAttributeNS(null, name(s)); s.in.peek(true); int c = s.in.read(); if(c != '=') @@ -114,7 +88,8 @@ public class Parser { buf.append((char)s.in.read()); } } - return(makeattr(s.doc, el, nm, buf.toString())); + a.setValue(buf.toString()); + return(a); } protected Element element(State s) throws IOException {