At 2018-05-16T23:47:29+05:30, N. Raghavendra wrote: > At 2018-05-16T13:49:52-04:00, John Clements wrote: > >> Would you (N. Raghavendra) be interested in taking the raw >> pseudo-documentation currently provided for ssax:make-parser and >> reformatting it into something useful, perhaps with an example? Would >> you (N. Raghavendra) be interested in taking the raw >> pseudo-documentation currently provided for ssax:make-parser and >> reformatting it into something useful, perhaps with an example? > > I'll draft something, and submit a PR to jbclements/sxml on GitHub.
I felt it was better to air the draft here, before submitting a PR. I am not familiar with Scribble, so I have written it in Emacs Org mode, and exported it to text. Please edit as deemed fit. Once the content is fixed, I can transcribe it into Scribble, and submit a PR. Raghu. ---------------------------------------------------------------------- ssax:make-parser ════════════════ ┌──── │ (ssax:make-parser new-level-seed-spec │ finish-element-spec │ char-data-handler-spec │ tag-spec ...) └──── Return a procedure of two arguments, an input port `xml-port', and an object `init-seed'. That procedure will parse the XML document produced by `xml-port', and the object `init-seed', according to the specifications `new-level-seed-spec', `finish-element-spec', `char-data-handler-spec', and `tag-spec's, and will return an object of the same type as `init-seed'. Arguments ───────── new-level-seed-spec = NEW-LEVEL-SEED new-level-seed-proc ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ `new-level-seed-spec' consists of the tag `NEW-LEVEL-SEED' in upper case, followed by a procedure `new-level-seed-proc'. This procedure must take the arguments `element-name', `attributes', `namespaces', `expected-content', and `seed'. It must return an object of the same type as `init-seed'. finish-element-spec = FINISH-ELEMENT finish-element-proc ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ `finish-element-spec' consists of the tag `FINISH-ELEMENT' in upper case, followed by a procedure `finish-element-proc'. This procedure must take the arguments `element-name', `attributes', `namespaces', `parent-seed', and `seed'. It must return an object of the same type as `init-seed'. char-data-handler-spec = CHAR-DATA-HANDLER char-data-handler-proc ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ `char-data-handler-spec' consists of the tag `CHAR-DATA-HANDLER' in upper case, followed by a procedure `char-data-handler-proc'. This procedure must take the arguments `string-1', `string-2', and `seed'. It must return an object of the same type as `init-seed'. tag-spec = tag tag-proc ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ TODO. Example ─────── Return a string containing the text, after removing markup, from the XML document produced by the input port `in'. ┌──── │ > (require racket/string sxml) │ │ │ > (define (remove-markup xml-port) │ (let* ((parser │ (ssax:make-parser NEW-LEVEL-SEED remove-markup-nls │ FINISH-ELEMENT remove-markup-fe │ CHAR-DATA-HANDLER remove-markup-cdh)) │ (strings (parser xml-port null))) │ (string-join (reverse strings) ""))) │ │ > (define (remove-markup-nls gi attributes namespaces expected-content │ seed) │ seed) │ │ > (define (remove-markup-fe gi attributes namespaces parent-seed seed) │ seed) │ │ > (define (remove-markup-cdh string-1 string-2 seed) │ (let ((seed (cons string-1 seed))) │ (if (non-empty-string? string-2) │ (cons string-2 seed) │ seed))) │ │ > (remove-markup │ (open-input-string │ "<foo>Hell<bar>o, world!</bar></foo>")) │ │ ⇒ "Hello, world!" └──── ---------------------------------------------------------------------- -- N. Raghavendra <ra...@hri.res.in>, http://www.retrotexts.net/ Harish-Chandra Research Institute, http://www.hri.res.in/ -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.