Electric Type

Multimedia

About Us

News

Help

The Fundamentals of XSSI

Page 3 — How to Use XSSI

The basic format of an XSSI command is as follows (the variables are shown in italics):

    <!--#element attribute="value" -->

But, of course, that tells you about as much as a president at a press conference. The key is to learn the different elements and how they work. The Apache XSSI documentation is very thorough, if a bit dry. We'll look at a few of the more useful commands:

The echo command prints the value of a variable as if you'd simply typed it in as part of your HTML (i.e., if the variable "elPresidente" is set to "nadav," then <!--#echo var="elPresidente" --> will print "nadav"). We'll discuss XSSI variables in more depth a little later on.

if, elif, else, endif ( <!--#if expr="test_condition" -->
     do what's here
<!--#elif expr="test_condition" -->
     do this instead
<!--#else -->
     do this one
<!--#endif -->
These so-called flow-control elements allow you to make documents display differently depending on the variable (such as which browser is being used or the time of day or whatever).

The "test condition" is evaluated by Apache and, if it is true, the code following it is executed (if there are XSSI statements following it) or printed (if text/HTML follows it). Test conditions can take various forms, which are detailed in the Apache docs.

For example, if the variable "election" is set to the value "rigged," <!--#if expr="$election = rigged" --> will evaluate as true, but <!--#if expr="$election = legit" --> will evaluate as false. One useful way of writing this code is to use forward slashes around the string to be matched. These tell Apache to try to match the string as a regular expression. In our example, <!--#if expr="$election = /rig/" --> would match whether "election" was set to "rigged" or "righteous" or "rigmarole." This command (the "I" in XSSI) inserts the contents of another file into the current file. At HotWired, we typically name fragments (files that are not complete HTML files) with the .htmlf extension. It's OK to include .html files, but be careful not to end up with a document that has multiple <html>, <head>, and <body> tags. For a complete how-to on server-side includes, check Liz's article.

This sets a variable. See the next page for more on XSSI variables.

next page»


Tutorials Home  

CSS Reference  

Regular Expressions  

Image Filtering  

Adding Site Search  

Image Maps  

Browser Detection  

Fundamentals of XSSI  

FTP Tutorial  

HTML 4.0  

User Blogs

Screen Shots

Latest Updates

Contact Us

Valid HTML 4.01!
Valid CSS!

Breadcrumb

© ElectricType
Maintained by My-Hosts.com
Site map | Copyright | Disclaimer
Privacy policy | Acceptable Use Policy
Legal information.