Re: Using XML::LibXML::SAX::Parser as replacement for XML::LibXML::SAX::Generator
Kjetil Kjernsmo <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
On Thursday 1. April 2010 11:57:59 Robin Berjon wrote: > On Apr 1, 2010, at 00:50 , Michael Ludwig wrote: > > Kjetil Kjernsmo schrieb am 31.03.2010 um 23:25:12 (+0200): > >> I'm writing a module that does some SAX filtering, and I start with a > >> DOM tree and end with a DOM tree. > > > > Maybe you're aware of that, or maybe you just want to exercise some > > SAX techniques, but when going from DOM to DOM (which means I don't > > have to worry about memory) it is much more convenient to use XSLT, a > > high-level language, than to use SAX, a rather low-level API. > > Not just XSLT in fact, you can also use XPath and modify the DOM in > place with Perl, for some uses it can be a lot simpler. OK. I've written a few thousand lines of XSLT, and has had many hours of pain in unspeakable places, so I figured I'd try a different XML technology this time. The point of this exercise is to write YA templating language. Everyone has to do that in their lifetime. In my case, I'm building a quick hack on RDFa, which is for embedding RDF data in (X)HTML. I realised that I could use RDF::RDFa::Parser with no modifications, and the XMLLiteral capability of RDF to do some variable substitutions. I have discussed this idea in the RDFa community, and there were those that weren't convinced it is a good idea, so I figured I'd make a quick hack to prove the concept rather than talk too much. Basically, I generate a SPARQL query based on the input document, run that query, get a table back, and then reinsert the values from that table into the result document. So, the idea here is that I need to do some variable substitutions. That's why I felt XSLT was the wrong tool for the job, I would have to do that programmatically, so a static stylesheet wouldn't do. Perhaps I could do something clever with a function, though... > Kjetil: do you have some code to show us so we could advise options? Sure! My RDF::RDFa::Template module (not yet on CPAN) is the example :-) More specifically, it would be great if you had a look at the current SAX Filter: http://svn.kjernsmo.net/RDF-RDFa- Template/trunk/lib/RDF/RDFa/Template/SAXFilter.pm It is almost there in terms of being ready for an alpha that can be discussed in the RDFa community. There are TODOs all over, but until I'm more confident this is actually a good idea, I'd leave them there. The three things I want to resolve before uploading to CPAN is this xmlns stripping problem, the doctype declaration, and finally, package a simple HTTP::Server::Simple script for people to try it out. I'm not strongly tied to any particular way of doing things, I just want to publish RSN :-) Cheers, Kjetil -- Kjetil Kjernsmo [email protected] http://www.kjetil.kjernsmo.net/ _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs