On Tue, Jun 21, 2011 at 01:58:08PM -0400, HP wei wrote:
I installed chicken.4.7.0
and ssax, sxpath
Then I tried to follow the examples pointed to in the ssax homepage
in
http://modis.ispras.ru/Lizorkin/sxml-tutorial.html
Generally, the Chicken documentation takes precedence over the
documentation of the upstream project (this goes for all eggs).
In this case, http://wiki.call-cc.org/egg/ssax
Specifically,
When I run this in csi,
(use ssax)
(use sxpath)
(sxml:document http://...html;)
I got
Error: unbound variable: sxml:document
Yes, sxml:document isn't part of the SSAX parser itself, but of
the xlink sublibrary of sxml-tools. Chicken's ssax egg packages
up purely the SSAX parser.
Sorry about the confusion, the upstream SSAX project is just a holy mess
of stuff which is split up in a way that's not very orthogonal.
We did our best to try to split it up into chunks that make sense for a
user so you don't have to make a choice to include everything and the
kitchen sink whenever you need *some* subfunctionality provided by the
SSAX project.
Another example, after installing htmlprag
(*html-sxml* http://modis.ispras.ru/Lizorkin/Apidoc/htmlprag.html
(open-input-resource http://html
http://modis.ispras.ru/Lizorkin/XML/amorphis.html))
-- gives
Error: unbound variable: open-input-resource
This is a very weird one; it doesn't exist _anywhere_ in the SSAX
project:
$ cvs -z3 -d:pserver:anonym...@ssax.cvs.sourceforge.net:/cvsroot/ssax co -P
sxml-tools
...
$ cvs -z3 -d:pserver:anonym...@ssax.cvs.sourceforge.net:/cvsroot/ssax co -P SSAX
...
$ grep -r open-input-resource SSAX sxml-tools
sxml-tools/xlink.scm: (let* ((port (open-input-resource req-uri))
sxml-tools/xlink.scm: (let* ((port (open-input-resource req-uri))
sxml-tools/xlink.scm: (let* ((port (open-input-resource req-uri))
sxml-tools/xlink.scm: (let* ((port (open-input-resource req-uri))
Only usage points, no definition at all!
On Dmitry Lizorkin's website there's this definition:
http://modis.ispras.ru/Lizorkin/Apidoc/access-remote.html#codefunc60351
which links to a http-transaction procedure here:
http://modis.ispras.ru/Lizorkin/Apidoc/http.html#codefunc26928
but neither of these exist in the SSAX source tree itself.
It can't really, since SSAX is (mostly) portable Scheme code,
but you can't portably open a network connection (scroll down
on that page to see cond-expand code that makes this available
in a sort-of portable way).
You could copy/paste this code, and it should probably work
unmodified, but read on for a better solution.
Do I need to use wget in the shell to download the html page
and then come back to csi to parse it ??
No, you can also use http-client, which provides a procedure which is
similarly high-level as open-input-resource:
(pp (call-with-input-request
http://modis.ispras.ru/Lizorkin/XML/poem.xml;
#f (lambda (p)
(let ((sxml (ssax:xml-sxml p '(
;; Consume the rest of the stream, ssax does not
;; fully read until the end.
(read-string #f p)
sxml
=
(*TOP* (*PI* xml version='1.0')
(poem (@ (title The Lovesong of J. Alfred Prufrock)
(poet T. S. Eliot))
(stanza
(line Let us go then, you and I,)
(line When the evening is spread out against the sky)
(line Like a patient etherized upon a table:))
(stanza
(line In the room the women come and go)
(line Talking of Michaelangelo.
For more information, see http://wiki.call-cc.org/egg/http-client
I hope this helps!
Cheers,
Peter
--
http://sjamaan.ath.cx
--
The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music.
-- Donald Knuth
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users