Kawa has a number of features for working with XML, HTML, and generated web pages.
In Kawa you don’t write XML or HTML directly. Instead you write expressions that evaluate to “node objects” corresponding to elements, attributes, and text. You then write these node objects using either an XML or HTML format.
Many web-page-generating tools require you to work directly with raw HTML, as for example:
(display "<p>Don't use the <code><blink></code> tag.</p>")
In Kawa you would instead do:
(display (html:p "Don't use the " (html:code "<blink>") " tag."))
The conversion from node objects to XML or HTML is handled by the formatter (or serializer). Some advantages of doing it this way are:
You don’t have to worry about quoting special characters. Missing or incorrect quoting is a common source of bugs and security problems on systems that work directly with text, such as PHP.
Some errors such as mismatched element tags are automatically avoided.
The generated generated XML can be validated as it is generated, or even using compile-time type-checking. (Kawa doesn’t yet do either.)
In application that also reads XML, you can treat XML that is read in and XML that is generated using the same functions.