From: msergeant@... (Matt Sergeant) Date: 2002-02-04T18:37:40+09:00 Subject: Re: Ruby + XML Proposal Bryan Murphy wrote in message news:<200202010813.g118DKJ14539@lokar.terralab.com>... > Because of the way the framework is built, these events are fired off to components > based upon their namespaces (if they don't exist in any particular namespace, they > are sent directly to the Serializer which sits at the end of the chain). Because > each event goes back to the same dispatcher, if XML document A includes XML > document B, and then XML document B includes XML document C, then XML document A > will be able to include XML document C as part of XML document B without you having > to do any extra work on your part (as long as they all agree on the same include > standard and you register the transformer that implements it). > > I can register as many of these transformers as I feel necessary. For instance, > what if I want to include a SQL statement in my XML document, execute the SQL > statement, and transform it's results into part of the XML document? Just write a > new transformer and register it. What if I want a looping construct to repeat a > part of the XML document a number of times? Create another transformer. Or how > about an XSL transformer that transforms only a part of the XML document, creates > an XInclude tag, and then the XInclude tag gets expanded out to contain the > contents of the included document? Very easy to implement! What you have essentially created here is SAX plus Namespace dispatch. This is exactly how AxKit's XSP module works - taglibs register themselves with a particular namespace, and the namespace dispatcher sends all tags with that namespace to the appropriate handler. Now there seems to be some people here who don't want standard APIs. Well I think that you should look at PerlSAX2 and PerlDOM. I'm not talking about XML::DOM, which is an implementation of the full DOM API though... PerlSAX2 basically said that while the Java SAX spec was nice, it doesn't map to Perl very well. Perl hackers don't want objects flying everywhere - too much overhead. So in Perl SAX2 events, the elements, attributes, PIs, etc are just Perl hashes. Now in Ruby you would surely use objects. But that should not force you to use the ugly Java API exactly as it is in the SAX spec. You should deviate from that towards more Ruby-like APIs where appropriate. Now PerlDOM is basically a layer over PerlSAX2 hashes - for every element you add in Parent and Children entries to the hash, and return that at the end of the parse phase. By using Mixins (which you can actually do in Perl), you can provide things over this layer such as XPath, full DOM APIs, etc. The point being you *can* do that stuff, but you don't have to. At the end of the day you've still got a dead simple language-centric layer that you can access directly. Anyway, something to think about. I'd love to see Ruby's XML support mature to the point where you can plugin SAX filters like you can now with Perl's SAX::Machines. You never know, I may switch completely from Perl then ;-)