<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">... and more interesting.<div><br></div><div>I am past the set-up phase and I got to the point of building a SAX parser (I have not figured out yet what is the practical difference between SAX and StAX).</div><div><br></div><div>My beef with XML is obviously increasing :) But let's not go there.</div><div>Here is my thinking.</div><div><br></div><div>I write <font class="Apple-style-span" face="'Courier New'">SAX:START-ELEMENT</font> methods and let each one of them look like</div><div><br></div><div><font class="Apple-style-span" face="'Courier New'">(defmethod sax:start-element ((h smbl-handler)</font></div><div><font class="Apple-style-span" face="'Courier New'"> namespace-uri</font></div><font class="Apple-style-span" face="'Courier New'"> (local-name (<font class="Apple-style-span" color="#FF0000">equal</font> "model"))<br> qname</font><div><font class="Apple-style-span" face="'Courier New'"> attributes) ...)</font></div><div><br></div><div><font class="Apple-style-span" face="'Courier New'">(defmethod sax:start-element ((h smbl-handler)<br> namespace-uri<br> (local-name (equal "compartment"))<br> qname<br> attributes) ...)</font></div><div><br></div><div><br></div><div>You get the idea...</div><div>Of course, we don't have EQUAL specializers (and I don't want to depend on "predicate dispatching" extensions :) ) so I did the following trick.</div><div><br></div><div><div><font class="Apple-style-span" face="'Courier New'">(defclass sbml-parser (sax:sax-parser) <font class="Apple-style-span" color="#FF0000">; Why do I need this?</font></font></div><div><font class="Apple-style-span" face="'Courier New'"> ()</font></div><div><font class="Apple-style-span" face="'Courier New'"> )</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">(defclass sbml-handler (sax:default-handler)</font></div><div><font class="Apple-style-span" face="'Courier New'"> ((source :reader sbml-handler-source :initarg :source)</font></div><div><font class="Apple-style-span" face="'Courier New'"> (pathname :reader sbml-handler-pathname :initarg :pathname)</font></div><div><font class="Apple-style-span" face="'Courier New'"> )</font></div><div><font class="Apple-style-span" face="'Courier New'"> )</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">(defclass sbml-symbolizer (cxml:sax-proxy) ())</font></div></div><div><br></div><div>... and ...</div><div><br></div><div><div><font class="Apple-style-span" face="'Courier New'">(defmethod sax:start-element ((h sbml-symbolizer)</font></div><div><font class="Apple-style-span" face="'Courier New'"> namespace-uri</font></div><div><font class="Apple-style-span" face="'Courier New'"> local-name</font></div><div><font class="Apple-style-span" face="'Courier New'"> qname</font></div><div><font class="Apple-style-span" face="'Courier New'"> attributes)</font></div><div><font class="Apple-style-span" face="'Courier New'"> (sax:start-element (cxml:proxy-chained-handler h)</font></div><div><font class="Apple-style-span" face="'Courier New'"> (intern namespace-uri)</font></div><div><font class="Apple-style-span" face="'Courier New'"> (intern local-name)</font></div><div><font class="Apple-style-span" face="'Courier New'"> (intern qname)</font></div><div><font class="Apple-style-span" face="'Courier New'"> attributes)</font></div><div><font class="Apple-style-span" face="'Courier New'"> )</font></div></div><div><br></div><div>So now I can write</div><div><br></div><div><div><font class="Apple-style-span" face="'Courier New'">(defmethod sax:start-element ((h smbl-handler)<br> (namespace-uri (eql '|http://www.smbl.org/sbml/level2/version4|))<br> (local-name (eql '|compartment|))<br> qname<br> attributes) ...)</font></div></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div>apart from the details... Do you guys think this is a sensible approach? It'd make writing the SAX parser a cinch.</div><div><br></div><div>Thanks</div><div><br><div>--<br>Marco Antoniotti<br><br></div><br></div></body></html>