examples/somexml.ss
#lang scheme

(require (prefix-in xml: "../xml.ss"))

(require srfi/19)

(xml:output (xml:join (xml:element "p" (xml:element "a" (xml:element "img" #:src (string-append "images" "/" "synx.jpg")) #:href "http://synx.us.to"))))

(display "\n---\n")

(xml:define-named-elements
  p a img)

(xml:output
 (p
  (a #:href "http://synx.us.to" (img #:src (string-join '("" "images" "synx.jpg") "/")))))

(display "\n---\n")

(define (a-document)
  (local
    [(xml:define-named-elements
       html head title link body h1)]
    (html
     (head
      (title "XML Maker")
      (link #:rel "stylesheet" #:href "style.css" #:type "text/css"))
     (body
      (h1 "XML Maker")
      (p "This document is an example of an XML document (not /quite/ XHTML) being generated not from a s-expression, but from normal scheme function calls.")
      (p "That allows you to create documents in the same language you program in, without any need for unfriendly concepts like quasiquoting. It avoids using quasiquote syntaxes to haphazardly mix two languages together, which though currently popular as HTML templates, is very error prone and hard to read by computers and humans alike.")
      (p "Also being scheme, using this module will make certain errors completely impossible, such as mismatched tags, unclosed tags, or unquoted attribute values.")
      (p "No escaping is needed, since these are just functions. " (date->string (current-date)))
      (p "It should be a simple abstraction, and you either get a full, valid document, or you get an error. Doing that means you can't stream the document, but that allows you to send a (full, valid) error document instead if an error is raised. Most documents are pretty small anyway, enough to fit it a reasonable sized 'chunk'")))))

(xml:output a-document)