[ssax-sxml] Re: How to get the namespace declarations?
Brought to you by:
oleg
From: <ol...@po...> - 2002-11-14 19:21:32
|
Hello! > > I have just added an example file into the SSAX CVS repository: > > SSAX/examples/daml-parse-unparse.scm > Sure? Which cvs repository? Not the sourceforge one, just checked. Hmm. Indeed. I distinctly remember committing the code. I did it again, and now it's definitely there: http://cvs.sf.net/cgi-bin/viewcvs.cgi/ssax/SSAX/examples/daml-parse-unparse.scm The code traverses the SXML tree twice: once to design the translation from SXML names to XML names and find out about all the namespaces; On the second traversal, the code emits XML. It is actually possible to do everything in only one pass. The latter would require a different traversal combinator (accum-pre-post-order rather than pre-post-order). Besides, it was past midnight already when I wrote the code, so I chose the easy way out. I have just noticed that I used a match-case special form, which is Bigloo specific: http://www-sop.inria.fr/mimosa/fp/Bigloo/doc/bigloo-6.html#pg1676 I believe many other systems have something similar (DrScheme, for example). match-case has a distinct feature: non-linear patterns. I don't use that feature however. Finally, http://cvs.sf.net/cgi-bin/viewcvs.cgi/ssax/SSAX/examples/pull-punct-sxml.scm defines a somewhat similar (but unoptimized) pattern matcher and the corresponding special binding form. However ungainly, the latter matcher can do what Bigloo's match-case can do. The latter matcher should run on any R5RS Scheme. > My requirements can be relaxed to > (lambda (str) > (string=? (xml-format (xml-parse (xml-format (xml-parse str)))) > (xml-format (xml-parse str)))) > => #t for any string str. which is, UNPARSE . PARSE . UNPARSE . PARSE === UNPARSE . PARSE The property above can be derived from the invariant of unparsing I claimed earlier, PARSE . UNPARSE . PARSE === PARSE by left-multiplying by 'UNPARSE'. That is, I do believe your requirements will be satisfied. > <offtopic> > Hey, what are you doing with agents? > </offtopic> ... described in the next message ;) Cheers, Oleg |