<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title> Practical PostgreSQL</title>
    <meta name="keywords" content="postgresql, support, recovery, design, software, hosting, expterise, programming, postgres, pgsql, replication, mysql, firebird, database, sql, free, open source, software" />
    <meta name="description" content="Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. " />
    <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="../css/layout.css" />
    <link rel="stylesheet" type="text/css" href="../css/cmd4.css" />
    <script language="javascript" type="text/javascript"><!--
      greymenuhomewideLit = new Image();
      greymenuhomewideLit.src = "/images/greymenu_homewide_lit.gif";
      greymenuaboutLit = new Image();
      greymenuaboutLit.src = "/images/greymenu_about_lit.gif";
      greymenuproductsLit = new Image();
      greymenuproductsLit.src = "/images/greymenu_products_lit.gif";
      greymenuservicesLit = new Image();
      greymenuservicesLit.src = "/images/greymenu_services_lit.gif";
      greymenusupportLit = new Image();
      greymenusupportLit.src = "/images/greymenu_support_lit.gif";
      greymenucommunityLit = new Image();
      greymenucommunityLit.src = "/images/greymenu_community_lit.gif";
    //--></script>
  </head>
  <body>
      <div align="center">
       <div id="widecontainer">
         <div id="widetop">
           <div class="throwleft" style="width: 300px; text-align: left;"><a href="http://www.commandprompt.com/"><img src="../images/cmd4logo_wide.gif" border="0" alt="Command Prompt, Inc." /></a></div>
           <div class="throwright" style="width: 400px; text-align: right;">
             <div id="topright">
               <form action="index.html" name="cmdform" method="post">
                 <ul>
                   <li><input type="text" name="search" value="" /></li>
                   <li><input type="submit" name="action" value="Search Book" /></li>
                 </ul>
               </form>
             </div>
           </div>
         </div>
          <ul id="greymenu_wide">
            <li><a href="http://www.commandprompt.com/home/"><img onmouseover="this.src = greymenuhomewideLit.src;" onmouseout="this.src = '/images/greymenu_homewide.gif';" src="../images/greymenu_homewide.gif" border="0" height="22" title="" alt="" /></a></li><li><img src="../images/greymenu_divider.gif" border="0" width="2" height="22" alt="|" /></li><li><a href="http://www.commandprompt.com/about/"><img onmouseover="this.src = greymenuaboutLit.src;" onmouseout="this.src = '/images/greymenu_about.gif';" src="../images/greymenu_about.gif" border="0" height="22" title="" alt="" /></a></li><li><img src="../images/greymenu_divider.gif" border="0" width="2" height="22" alt="|" /></li><li><a href="http://www.commandprompt.com/products/"><img onmouseover="this.src = greymenuproductsLit.src;" onmouseout="this.src = '/images/greymenu_products.gif';" src="../images/greymenu_products.gif" border="0" height="22" title="" alt="" /></a></li><li><img src="../images/greymenu_divider.gif" border="0" width="2" height="22" alt="|" /></li><li><a href="http://www.commandprompt.com/services/"><img onmouseover="this.src = greymenuservicesLit.src;" onmouseout="this.src = '/images/greymenu_services.gif';" src="../images/greymenu_services.gif" border="0" height="22" title="" alt="" /></a></li><li><img src="../images/greymenu_divider.gif" border="0" width="2" height="22" alt="|" /></li><li><a href="http://www.commandprompt.com/support/"><img onmouseover="this.src = greymenusupportLit.src;" onmouseout="this.src = '/images/greymenu_support.gif';" src="../images/greymenu_support.gif" border="0" height="22" title="" alt="" /></a></li><li><img src="../images/greymenu_divider.gif" border="0" width="2" height="22" alt="|" /></li><li><a href="http://www.commandprompt.com/community/"><img onmouseover="this.src = greymenucommunityLit.src;" onmouseout="this.src = '/images/greymenu_community.gif';" src="../images/greymenu_community.gif" border="0" height="22" title="" alt="" /></a></li>          </ul>

  
        <div style="padding-left: 16px; width: 96%;">
          <HTML
><HEAD
><TITLE
>Understanding LXP Mark-Up</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.72
"><LINK
REL="HOME"
TITLE="Practical PostgreSQL"
href="book1"><LINK
REL="UP"
TITLE="LXP"
href="lxp"><LINK
REL="PREVIOUS"
TITLE="Installing and Configuring LXP"
href="x21206"><LINK
REL="NEXT"
TITLE="LXP Variables and Objects"
href="x21491"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Practical PostgreSQL</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
href="x21206"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 13. LXP</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
href="x21491"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN21430"
>Understanding LXP Mark-Up</A
></H1
><P
>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 <SPAN
><I
CLASS="EMPHASIS"
>tags</I
></SPAN
>.</P
><P
>Here is an introductory example of a simple LXP document:</P
><PRE
CLASS="SCREEN"
>&#60;lxp&#62;
  &#60;dock type="init"&#62;
    &#60;include src="parts/init.lxp" /&#62;
  &#60;/dock&#62;
  &#60;include src="parts/head.html" /&#62;
  
  &#60;h1&#62;Welcome&#60;/h1&#62;
  
  &#60;hr width="400"&#62;
  
  &#60;if lxp.authenticated='t'&#62;
    Welcome to my webpage, &#60;putcookie name="user" /&#62;
  &#60;/if&#62;
  &#60;else&#62;
    &#60;strong&#62;Please login.&#60;/strong&#62;
    &#60;include src="parts/login.lxp" /&#62;
  &#60;/else&#62;
  
  &#60;include src="parts/foot.html" /&#62;
&#60;/lxp&#62;</PRE
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN21439"
>LXP Tags</A
></H2
><P
>A tag (formally called an <SPAN
><I
CLASS="EMPHASIS"
>element</I
></SPAN
>) is defined as a structure in a document beginning with a
      less-than symbol (<TT
CLASS="LITERAL"
>&#60;</TT
>) and ending with a greater-than symbol
      (<TT
CLASS="LITERAL"
>&#62;</TT
>). Tags always begin with a name, which defines the nature of the tag, and can
      optionally have a set of space-delimited <SPAN
><I
CLASS="EMPHASIS"
>attributes</I
></SPAN
>. Attributes are always described in the form of a
      <TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
><TT
CLASS="LITERAL"
>=</TT
><TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
> pair, where 
      <TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
> is an attribute name unique to that tag, and <TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
> is some arbitrary value
      assigned to that attribute.</P
><P
>All of LXP's tags follow the same general structure of any mark-up language. Tags begin a <SPAN
><I
CLASS="EMPHASIS"
>region</I
></SPAN
>
      (or <SPAN
><I
CLASS="EMPHASIS"
>block</I
></SPAN
>) with an <SPAN
><I
CLASS="EMPHASIS"
>opening</I
></SPAN
> tag (e.g.,
      <TT
CLASS="LITERAL"
>&#60;tag&#62;</TT
>), and close each region with an associated slash-prefixed
      <SPAN
><I
CLASS="EMPHASIS"
>closing</I
></SPAN
> tag (e.g., <TT
CLASS="LITERAL"
>&#60;/tag&#62;</TT
>.</P
><P
>As with HTML and XML, some tags do not require closing. These are called <SPAN
><I
CLASS="EMPHASIS"
>empty element</I
></SPAN
> tags, and
      do not define a region, but perform a one-time operation. Empty element tags are typically characterized by a trailing
      forward slash at the end of the tag (e.g., <TT
CLASS="LITERAL"
>&#60;tag /&#62;</TT
>.</P
><P
>LXP's parser does not syntactically require trailing-slashes in empty element tags, though omitting them can cause
      unpredictable behavior in some circumstances. For example, nesting the <TT
CLASS="LITERAL"
>&#60;include&#62;</TT
> tag
      can cause some confusion to branching logic if trailing slashes are omitted. This is because the
      <TT
CLASS="LITERAL"
>&#60;include&#62;</TT
> tag may be either an empty-element tag (as in the case of an external
      document inclusion), or an opening tag requiring a closing tag (as in the case of the direct SQL inclusion).</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>It is a good idea to be in the habit of using trailing slashes in empty-element tags. In HTML, some tags do not
        formally require a trailing slash (e.g., <TT
CLASS="LITERAL"
>&#60;br&#62;</TT
> versus XHTML's
        <TT
CLASS="LITERAL"
>&#60;br /&#62;</TT
>). With the rise of XHTML and XML, however, requirements for
        mark-up&#8211;based documents are becoming more strict.</P
></BLOCKQUOTE
></DIV
><P
>Both opening and empty-element tags have names, and may also contain some number of attributes. While the name
      describes the intent of a tag, the attributes typically define the <SPAN
><I
CLASS="EMPHASIS"
>details</I
></SPAN
> of the operation to be
      performed, and vary in their meaning from tag to tag. A closing tag should only have a name, immediately following its
      initial forward slash (e.g., <TT
CLASS="LITERAL"
>&#60;/tag&#62;</TT
>).</P
><P
>LXP tag and attribute names are generally case-insensitive, though there are times when an attribute name refers
      literally to a variable's name (such as in the <TT
CLASS="LITERAL"
>&#60;if&#62;</TT
> tag). In these instances, case
      can matter, depending on the case conventions you use with your variables. The examples in this document prefer lowercase,
      following the lead of the XHTML standard (which defines element names and attributes as all lowercase).</P
><P
><A
href="x21430#ASIMPLELXPMARKUPREGION"
>Example 13-6</A
> shows a simple LXP mark-up region with one opening tag, one closing tag, and
      two empty-element tags within their defined region.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="ASIMPLELXPMARKUPREGION"
></A
><P
><B
>Example 13-6. A Simple LXP mark-up region</B
></P
><PRE
CLASS="SCREEN"
>&#60;lxp&#62;
  &#60;setvar example="test" /&#62;
  &#60;putvar name="example" /&#62;
&#60;/lxp&#62;</PRE
></DIV
><P
>LXP aims for simplicity and seamlessness in application development, and this basic structural aspect of LXP is an
      example of this ethic.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="LXPREGIONS"
>LXP Regions</A
></H2
><P
>Arguably the most important LXP tag is the <TT
CLASS="LITERAL"
>&#60;lxp&#62;</TT
> tag itself, which enables an
      <SPAN
><I
CLASS="EMPHASIS"
>LXP region</I
></SPAN
>. This is similar to a &#60;script&#62; tag, or the PHP short tag, in that it instructs the
      LXP module to begin looking for LXP content.</P
><P
>Unlike PHP, however, while parsing an LXP region the module will simply ignore any tags that it does not recognize as
      an LXP tag. The <TT
CLASS="LITERAL"
>&#60;lxp&#62;</TT
> tag simply enables the ability to use LXP tags in a given
      region without impairing your ability to write normal HTML mark-up (though the effect of LXP tags can control which parts
      of the HTML are displayed).</P
><P
>It should follow from this discussion that <TT
CLASS="LITERAL"
>&#60;/lxp&#62;</TT
> closes an LXP region and
      disables the ability to use LXP tags until the next <TT
CLASS="LITERAL"
>&#60;lxp&#62;</TT
> tag is opened.</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>An LXP document does not automatically look for LXP tags. A document will be rendered faster if LXP regions are
        limited to areas requiring LXP capabilities, as it is more involved to parse an LXP region for dynamic content than it is
        to process a plain HTML region.</P
></BLOCKQUOTE
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
href="x21206"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
href="book1"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
href="x21491"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Installing and Configuring LXP</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
href="lxp"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>LXP Variables and Objects</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
        </div>
        <br />
        

          <div id="thefineprint">
            <a href="http://www.commandprompt.com/products/mammothpostgresql/"><img src="../images/powered_by_mammoth.gif" alt="Powered by Mammoth PostgreSQL" title="Powered by Mammoth PostgreSQL" border="0" /></a>
                        <br />
            Copyright &copy; 2000-2007 Command Prompt, Inc. All Rights Reserved. All trademarks property of their respective owners.
          </div>
        </div>
      </div>
  </body>
</html>