Chapter 13. LXP

Table of Contents
Why Use LXP?
Core Features
Installing and Configuring LXP
Understanding LXP Mark-Up
LXP Variables and Objects
Using Cookies with LXP
Tag Parsing
Branching Logic
Loop Iteration
Content Inclusion
Displaying Foreign Tags with <xtag>

LXP (or mod_lxp) is an Application Server designed as an Apache Module. LXP is used to broker and dynamically format HTML content through a process called server-side inclusion. This involves assembling HTML output from a variety of sources, which can include HTML source files, XML files, or even data within a PostgreSQL database.

LXP's content inclusion is performed entirely on the server, ensuring the same output regardless of the web browser. LXP is intended to behave more intuitively, seamlessly, and comprehensively than other available content inclusion methods via its unique mark-up based approach and native PostgreSQL connectivity.

LXP uses a unique form of programmatic mark-up tags, which are interpreted entirely on the server and translated into standard HTML output before being sent to the client. While the effects of these tags are programmatic in nature, they differ from a "scripting language" such as PHP or Perl, by relying for their implementation on the same structural concepts as those behind HTML and XML for their implementation.

One of the goals of LXP is to provide dynamic, conditional capabilities that do not violate the syntax and methodology of a mark-up–based document. An LXP document should be readable to anyone fluent in HTML, though the meaning of the extra tags may not be immediately obvious. Simultaneously, experienced programmers can take advantage of the more advanced features within the content model of LXP.

Why Use LXP?

LXP provides a simple way to build powerful web sites without using a "programming" language. If you can use mark-up, you can use LXP to help provide dynamically manageable content.

Additionally, LXP's integration with PostgreSQL allows for a deeper degree of content in your web sites. Traditionally, if you wanted to perform logic on result sets from a database, you would have to use PHP, Perl, or compiled C or C++. With LXP, use of such languages is no longer required.

Using LXP allows you to utilize the power of PostgreSQL's features—including user-defined functions, triggers, and procedural languages (such as PL/pgSQL)—to provide the logic for your data. With LXP, there is no longer a need to use complicated programming languages for the majority of your simple tasks. Even mathematical operations, date and time evaluations, and involved string formatting can be performed with LXP, via the connection to PostgreSQL.

While this simplicity is one of LXP's strengths, we understand that sometimes a more comprehensive solution is required (or simply preferred) for the design of a given function. For this reason, if you need the power of a comprehensive programming language in part of your web site, you can use either of LXP's Apache or URI methods to embed any available document type within LXP-managed output.