Need help transforming some deep structures
Kjetil Kjernsmo <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
Hi all! I'm working on a new module RDF::RDFa::Template, which is an idea I have described here: http://www.kjetil.kjernsmo.net/software/rat/ and discussed at some length in the RDF community. So, I figured, rather than talk about it, I write the code and discuss from there. After all, rough consensus and running code beats total consensus and no code any day. :-) I have most of the code for a first iteration of the idea now, but what I need is to transform this: http://svn.kjernsmo.net/RDF-RDFa-Template/trunk/t/data/dbpedia- comment.input.xhtml into that: http://svn.kjernsmo.net/RDF-RDFa-Template/trunk/t/data/dbpedia- comment.expected.xhtml Here, the rat:graph elements are removed, and rat:variable elements has its values substituted based on the results of a SPARQL Query, which is done elsewhere in the code (and now works). A doctype is also inserted and some namespace declarations are removed. The input document is in the form of an XML::LibXML::Document object when this process starts, so I would like to stick to stuff based on XML::LibXML. My idea is write a SAX Filter, and I have started doing that, based on Kip's articles from way back, and I have understood that I should somehow accumulate events as I go, and finally add them in the final end_element, but since the structure is somewhat deep, I haven't understood the details. I had a look at XML::Filter::DOMFilter::LibXML too, but I quite see if this would be the right thing to use; although I copy most of the children of rat:graph, which would be nice to use DOM, I also do the substitution in there. Once I release this, I will solicit comments of the RDF(a) community and if people like the idea, to make this useful, it has to be several rat:graph elements in a document, and the filter should process all these elements. Also, importantly, if the SPARQL query returns multiple results, the child elements of rat:graph should be copied for each solution. But this is the next iteration, so it is not a priority now. Can anyone please advice on how I should do this? 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