Re: sxml dom
[email protected] Thu, 16 Dec 2004 22:00:52 -0800 (PST)
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <[email protected]> |
Hello!
> Actually, it's not an application, it's a library that renders
> CSS-styled XML formats (like Mozilla XUL) for console display with
> ncurses.
I think I know what you mean. Isn't it like the following:
<!-- Example of DHTML via a PerlScript: a simple calculator -->
<HTML><HEAD><TITLE>DHTML PerlScript Calculator</TITLE>
<script Language="PerlScript">
sub Eval_onClick
{
$window->RESULTS->{innerHTML} = eval $window->EXPRESSION->value;
}
</script>
</head>
<body>
<H1 align="center">DHTML PerlScript Calculator</H1>
<P>Enter the expression to evaluate:
<input type=text size=60 id=EXPRESSION>
<input type=button name=Eval Value="Eval">
<P>The result is:
<div id=RESULTS style="color:red; font-weight:bold;"></div>
</body></html>
[which is my first and only PerlScript program as of five years ago].
That is, you wish to attach handlers to some HTML elements (like
the onClick handler to the element with ID=Eval). Within that handler, you
want to be able to retrieve the value of some HTML element, replace
the children of some other element (RESULTS) with new (S)HTML, and
re-render the page. Right?
That seems to be quite easy in SXML. Attaching a script to a node is
trivial -- it is merely adding an attribute such as 'onclick' to the
needed node. The value of such an attribute is a Scheme procedure.
Retrieving the value of a node can be done with a SXPath query: e.g.,
(sxpath '(// (* (@ (equal? (id "EXPRESSION"))) *text*)))
Actually, SXPathlib maintains the hash of node's IDs, which greatly
simplifies the above query and makes it more efficient. Likewise one
can replace the children of an element with new SXML code. Kirill's
STX seems to be quite relevant:
http://pair.com/lisovsky/transform/stx/
He or Dmitry Lizorkin can tell much more about that. I seem to
remember Kirill's mentioning of some kind of XUL support in Chicken
Scheme (with the help of XSLT). Perhaps Kirill might clarify.
Cheers,
Oleg
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/