[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SXML (was: Re: loading additional code)



Hello!

On Sun, 6 Jan 2002, Wojciech Sobczuk wrote:

> 	<mz:sometag a "bcd" e "fgh"> content </mz:sometag>
> translates to:
> 	(sometag 'a "bcd" 'e "fgh" content)
> 

You may consider SXML also:
http://okmij.org/ftp/Scheme/SXML.html
In SXML attribute names may be bound to functions (and evaluated) as well as tag names,
it provides support for Namespaces and PIs, it is highly suitable for XPath queries, etc.
An example is below.

On 6 Jan 2002, David N. Welton wrote:

> Wojciech Sobczuk <sopel@freebsd.hbz.pl> writes:
> 
> > *AND* i need a nice environment to complete two large web projects
> > (and i also need to convince others that it's better than PHP which
> > 'everyone knows')..
> 
> If the group here will pardon some slightly off topic comments, I
> think you need to look at what people like about PHP - to wit, that
> it's easy to get aquainted with and start using, especially for people
> who don't have a lot of programming experience, or for those who have
> seen a little bit of this and that and want to get started quickly.
SXML proves itself really useful for "quick-start" XML-related projects.
I'm using it in production for two years, usually with SXPath and SSAX parser.

XML element (which is also valid XHTML element)

<tr align="left" valign="top">
  <td><i>First</i></td>
  <td><b>Second</b></td>
  <td><b>Third</b></td>
  <td><a href="http://ssax.sf.net";>link</a></td>
</tr>

may be represented in SXML as 

'(tr 
   (@ (align "left")       ; List of 
      (valign "top"))      ; attributes
   (td (i "First"))  
   (td (b "Second"))       ; Empty list of attributes may be omitted
   (td (@) (b "Third"))    ; ... or present, it doesn't matter.
   (td (a (@ (href "http://ssax.sf.net";)) "link")))

It may be also queried using SXPath:
("node" is S-expression above)

((sxpath '(td b)) node)
=>  ((b "Second") (b "Third"))

((sxpath '(td a @ href *text*)) node)
=>  ("http://ssax.sf.net";)


Libraries necessary:
http://pair.com/lisovsky/download/ssax/ssax-plt-49.tgz
(it provides a _minimalistic_ example also)
http://pair.com/lisovsky/download/SXPathlib.scm

More information may be found at 
http://ssax.sf.net

Best regards,
          Kirill.