Understanding LXP Mark-Up

While LXP performs programmatic tasks, one of the aims of LXP is to achieve these tasks without having to change the general syntax that one uses when putting together HTML (or XHTML) mark-up. On the server, an LXP document appears to be a normal HTML file with some unfamiliar tags.

Here is an introductory example of a simple LXP document:

<lxp>
  <dock type="init">
    <include src="parts/init.lxp" />
  </dock>
  <include src="parts/head.html" />

  <h1>Welcome</h1>

  <hr width="400">

  <if lxp.authenticated='t'>
    Welcome to my webpage, <putcookie name="user" />
  </if>
  <else>
    <strong>Please login.</strong>
    >include src="parts/login.lxp" />
  </else>

  <include src="parts/foot.html" />
</lxp>

LXP Tags

A tag (formally called an element) is defined as a structure in a document beginning with a less-than symbol (<) and ending with a greater-than symbol (>). Tags always begin with a name, which defines the nature of the tag, and can optionally have a set of space-delimited attributes. Attributes are always described in the form of a name=value pair, where name is an attribute name unique to that tag, and value is some arbitrary value assigned to that attribute.

All of LXP’s tags follow the same general structure of any mark-up language. Tags begin a region (or block) with an opening tag (e.g., <tag>), and close each region with an associated slash-prefixed closing tag (e.g., </tag>.

As with HTML and XML, some tags do not require closing. These are called empty element tags, and do not ...

Get Practical PostgreSQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.