Marco Antoniotti kindly exported `def-element` from [`xhtmlambda`](https://xhtmlambda.common-lisp.dev/) for us after [yesterday's sunday-morning-in-europe](https://toobnix.org/w/evepEXh69p6YaWYsPe6rLs). 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](https://ar.al/)'s [Kitten](https://kitten.small-web.org/) being played with by common lisp.

> [xhtmlambda example with def-element at the end now.](./#xhtmlambda-example-added)

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](https://www.ida.liu.se/ext/aica/)'s __thingtype__ .. __attributes__ etc for `xml` contexts. `xml` is obviously the basis for [w3's semantic web](https://www.w3.org/2001/sw/wiki/Main_Page) 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](https://gamerplus.org/@screwlisp/115918934703044274).

## 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>
```