manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.16 sxml-match: Pattern Matching of SXML

The (sxml match) module provides syntactic forms for pattern matching of SXML trees, in a “by example” style reminiscent of the pattern matching of the syntax-rules and syntax-case macro systems. See section SXML, for more information on SXML.

The following example(26) provides a brief illustration, transforming a music album catalog language into HTML.

(define (album->html x)
  (sxml-match x
    [(album (@ (title ,t)) (catalog (num ,n) (fmt ,f)) ...)
     `(ul (li ,t)
          (li (b ,n) (i ,f)) ...)]))

Three macros are provided: sxml-match, sxml-match-let, and sxml-match-let*.

Compared to a standard s-expression pattern matcher (see section Pattern Matching), sxml-match provides the following benefits:

The present module is a descendant of WebIt!, and was inspired by an s-expression pattern matcher developed by Erik Hilsdale, Dan Friedman, and Kent Dybvig at Indiana University.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 20, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.