From: Michael T. <mt...@bb...> - 2004-10-06 15:44:50
|
Just to be clear, I invented my method because: 1. there is no need to define a function for each tag/attr - it is all data. 2. it factors the formatting from the xml - e.g. the difference between rdf and n3 syntaxes is strictly on the formatting side. 3. there is less that is implied by structure - although Geoffrey's technique results in easier to read structure, the tag vs attr differentiation is not explicit. I suppose this is just a matter of a slightly higher-level representation. I guess I might prefer Geoffrey's if I were writing lots of code by hand - my use, however, generates lots of xml from a much higher-level structure, and I was having to do things like (eval `(geoffs-form...)). bleah! cheers, -mik Ken Anderson wrote: >Mike Thome came up with a way of generating indented HTML. >The basic idea is rather than going form s-expressions to XML >directly, you go from s-expression -> XML equivalent s-expression and >then write a xml pretty printer that outputs the equvalent xml text >from the s-expression. > >Our s-expression XML notatation represents XML as >`(,tag . ,body) > >Where tag is either a symbol or `(,symbol . ,attributes) >where attributes is a list of either a symbol or `(,attribute ,value). >And body is a sequence of XML. > >The changes to the code i sent out the other day are simply: > >(define (xtag tag) > (lambda (as . bs) > (let ((as (if (pair? (car as)) as > (list as)))) > (if (pair? as) (cons (cons tag as) bs) > (cons tag bs))))) > >(define (xatt name) (lambda (x) (list name x))) > >So there are 2 more ways to generate XML. > >W1: Use Geoffrey's technique as before. OK, this isn't new, just a >mod. > >(owl:DatatypeProperty > (rdf:ID name) > (rdfs:comment (rdf:datatype "&xsd:#string") > documentation) > (rdfs:domain (rdf:resource class)) > (rdfs:range (rdf:resource "&xsd;#string"))) > >W2: Use quasiquote to construct the xml s-expression: > >`((owl:DatatypeProperty (rdf:ID ,name)) > ((rdfs:comment (rdf:datatype "&xsd:#string")) > ,documentation) > ((rdfs:domain (rdf:resource ,class))) > ((rdfs:range (rdf:resource "&xsd;#string")))) > > > >------------------------------------------------------- >This SF.net email is sponsored by: IT Product Guide on ITManagersJournal >Use IT products in your business? Tell us what you think of them. Give us >Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more >http://productguide.itmanagersjournal.com/guidepromo.tmpl >_______________________________________________ >Jscheme-user mailing list >Jsc...@li... >https://lists.sourceforge.net/lists/listinfo/jscheme-user > > |