screwlisp proposes kittens

The gist of kitten and xhtmlambda

| link | Last. 20260119T000608684Z |

Marco Antoniotti kindly exported def-element from xhtmlambda for us after yesterday’s sunday-morning-in-europe. We had a small discussion as to why. def-element lets you make your own xml ontologies (er, the default of html5 is also useful for websites). I had used it to sketch an RSS 2.0 ontology. This advancement of xhtmlambda has extremely important implicatations for Aral Balkan’s Kitten being played with by common lisp.

xhtmlambda example with def-element at the end now.

By the way, this article was written by me without approval by either Marco or Aral.

I am calling this an ontology because def-element makes a symbol into a type of thing with explicit specific-attributes (and also categories, context, content and documentation). So [xml] element in xhtmlambda is loosely equivalent to Sandewall’s Leonardo System’s thingtype 
 attributes etc for xml contexts. xml is obviously the basis for w3’s semantic web which is a younger relative of Sandewall’s Leonardo System.

One place I use locally defined xml ontologies is kitten. By the way, I am sure you, o webdev, can come up with something better websitewise than this, which is actually how my blog currently works. This is how the heading constructions in my blog are defined (“in md”):

H.fragment.md

${'#'.repeat(SLOT.level)} ${SLOT.text}
| [link](${SLOT.link}) | Last. __${SLOT.date}__ |

H then becomes a kitten xml element, which I currently use like this:

<${H}>
	<content for='text'>${Data.section1.H.text}</content>
	<content for='link'>${Data.section1.H.link}</content>
	<content for='date'>${Data.section1.H.date}</content>
	<content for='level'>${Data.section1.H.level}</content>
</>

<${Section1}></>

where the Section1 element comes from the existence of the file this-post/md/Section1.fragment.md.

The json oddities are because kitten provides a json based application database for generating static or dynamic pages, and the generated xml / html goes through strict sanitization to stop some standard website attacks from being possible.

Until now, I have been generating these xml structures from emacs lisp in quite a haphazard template-based way. However now with xhtmlambda, I can define an ontology of elements (on kitten’s side, each of these elements is a element-name.fragment.md) and use a common lisp sexp like

(article
 (${H}
  ((content :for "text") "${Data.section1.H.text}")
  ((content :for "link") "${Data.section1.H.link}")
  ((content :for "date") "${Data.section1.H.date}")
  ((content :for "level") "${Data.section1.H.level}"))
 (${Section1}))

Which one can macro up in common lisp’s templating (let ((foo 'bar)) '((foo :baz ,foo) buzz)) ⼕ ((foo :baz bar) buzz) ⼕ <foo baz="bar">buzz</foo>.

Well, it will directly make my life easier and plant the xml / blog generation squarely in common lisp (still using an ontology of kitten fragments as the xml elements).

See you on the Mastodon thread.

xhtmlambda example added

It is like this. https://xhtmlambda.common-lisp.dev/

CL-USER> (require :xhtmlambda)
;;; Computing Hangul syllable names
NIL
CL-USER> (in-package :xhtmlambda)
#<PACKAGE "IT.UNIMIB.DISCO.MA.XHTMLAMBDA">
<> (def-element foo :specific-attributes (bar))
IS-FOO
<> (def-element baz)
IS-BAZ
<> (def-element buzz :specific-attributes (frob))
IS-BUZZ
<> (with-html-syntax-output 
       (t)
       ((foo :bar "coelacanth")
	"dodo"
	(baz "harpagonis")
	((buzz :frob "Marsupial lion"))
	"moa"))
<foo bar="coelacanth">
    dodo
    <baz>
        harpagonis
    </baz>
    <buzz frob="Marsupial lion" />
    moa
</foo>
screwlisp proposes kittens