home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13h.zip / xssi.sht < prev    next >
Text File  |  1999-06-01  |  6KB  |  181 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3 Organization//DTD W3 HTML 2.0//EN">
  2. <html>
  3. <head>
  4. <title>The XSSI extensions</title>
  5. </head>
  6. <body>
  7.  
  8. <P>
  9.  
  10. <h2 align="center">The XSSI extensions to SRE-http </h2>
  11. SRE-http supports a subset of the <tt>Apache XSSI</tt> extensions 
  12. to the NCSA HTTPD server side includes</em>:
  13. <dl>
  14. <!--  !  #SET  ******** -->
  15. <dt> <!-- #set var="varname" value="some value" -->
  16. <dd>
  17. <tt>#set</tt> is used to define variables for use  in other 
  18. HTTPD-style server side includes. 
  19. <ul>
  20. <li><tt>var</tt>: The name of the variable to set.
  21. <li><tt>value</tt>: value to give a variable. 
  22. </ul>
  23. For example:<br>
  24.   <CODE><!--#set var="category" value="help" --></CODE><br>
  25. <p>
  26.  
  27. <!-- ! #IF ********* -->
  28. <dt>
  29.     <!--#if expr="<I>test_condition</I>" -->
  30.     <!--#elif expr="<I>test_condition</I>" -->
  31.     <!--#else -->
  32.     <!--#endif -->
  33.  
  34. <dd> The <B><CODE>if</CODE></B> element works like an
  35.     if statement in a programming language.  The test condition
  36.     is evaluated and if the result is true, then the text until
  37.     the next <B><CODE>elif</CODE></B>, <B><CODE>else</CODE></B>.
  38.     or <B><CODE>endif</CODE></B> element is included in the
  39.     output stream.
  40.  
  41. <P> The <B><CODE>elif</CODE></B> or <B><CODE>else</CODE></B>
  42.     statements are used if the original test_condition is false.  
  43.     These elements are optional. Note that the first
  44.     <em>true</em> statement is used, and  <code>else</code>
  45.     is <b>always</b> true (it does NOT take an <code>expr</code>).
  46.  
  47. <P> The <B><CODE>endif</CODE></B> element ends the 
  48.     <B><CODE>if</CODE></B> element and <b>is required</b>.
  49.  
  50. <P> <I>test_condition </I> can be any valid REXX statement.
  51. In addition, the following Apache (C) style comparions
  52.  are also supported:<blockquote>
  53.  
  54. <DL>
  55.  
  56. <DT><tt><I>string</I><DD>true if <I>string</I></tt> is not empty
  57.  
  58. <DT><tt><I>string1</I> = <I>string2</I></tt><BR>
  59.  
  60. <DD>Compare string1 with string 2. 
  61.  
  62. <DT><tt><I>string1</I> != <I>string2</I></tt><BR>
  63. <DD>Compare string1 with string 2, TRUE if not equal. 
  64.  
  65. <DT><tt>( <I>test_condition </I> )</tt>
  66.         <DD>true if <I>test_condition</I> is true 
  67. <DT><tt>! <I>test_condition </I></tt>
  68.         <DD>true if <I>test_condition </I> is false
  69. <DT><tt><I>test_condition1 </I> && <I>test_condition2 </I></tt> 
  70.  
  71.         <DD>true if both <I>test_condition1 </I> and
  72.         <I>test_condition2</I> are true 
  73. <DT><tt><I>test_condition1 </I> || <I>test_condition2 </I> </tt>
  74.  
  75.         <DD>true if either <I>test_condition1</I> or
  76.         <I>test_condition2</I> is true 
  77. </DL>
  78.  
  79. <P> "<I>=</I>" binds more  tightly than "<I>&&</I>" and
  80.     "<I>||</I>". 
  81.     "<I>!</I>" binds most tightly.  Thus, the following are equivalent:
  82.  
  83. <PRE>
  84.     <!--#if expr="$a = test1 && $b = test2" -->
  85.     <!--#if expr="($a = test1) && ($b = test2)" -->
  86. </PRE>
  87.  
  88.  
  89. </dl>
  90. </blockquote>
  91. Would you like to <a href="iftest.sht">see a demo of #IF</a>
  92.  
  93. <hr width="40%">
  94. <H2>Using #set variables</H2>
  95. <P> #set variables are used as <em>textual substitutions</em>
  96.     within quoted. This substituion is performed
  97.     where they may reasonably occur as an argument to an SSI directive.
  98.     This includes the
  99.     <SAMP>config</SAMP>,
  100.     <SAMP>exec</SAMP>,
  101.     <SAMP>flastmod</SAMP>,
  102.     <SAMP>fsize</SAMP>,
  103.     <SAMP>include</SAMP>, and
  104.     <SAMP>set</SAMP>
  105.     directives, as well as the arguments to conditional operators.
  106. <p><b>Notes:</b><menu>
  107. <li>In order to insert a literal dollar sign into an NCSA-style
  108.            SSI directive, you must use the backslash (\) character
  109.            as a quote:
  110.  
  111. <PRE>
  112.     <!--#if expr="$a = \$test" -->
  113. </PRE>
  114.  
  115. <li> If a variable reference needs to be substituted in the middle of a
  116.     character sequence that might otherwise be considered a valid
  117.     identifier in its own right, it can be disambiguated by enclosing
  118.     the reference in braces. For example:
  119.  
  120. <PRE>
  121.     <!--#set var="Zed" value="${REMOTE_HOST}_${REQUEST_METHOD}" -->
  122. </PRE>
  123.  
  124. <P> This will result in the <SAMP>Zed</SAMP> variable being set to
  125.     "<SAMP>X_Y</SAMP>" if <SAMP>REMOTE_HOST</SAMP> is
  126.     "<SAMP>X</SAMP>" and <SAMP>REQUEST_METHOD</SAMP> is
  127.     "<SAMP>Y</SAMP>".
  128. <br><br>
  129. <li> When using a #set variable in an #ECHO element, you should 
  130. <b>not</b> include the $ preface. For example, assuming you've
  131. defined <tt> <!-- #set var="foo" value="hello world" --></tt>,
  132. then:
  133. <menu>
  134. <li><B>Correct</b>: <!-- #echo var="foo" --> 
  135. <li><B>InCorrect</b>: <!-- #echo var="$foo" --> 
  136. </menu>
  137.  
  138. <li> You can reference regular <em>CGI</em> variables
  139. using the $ syntax (as noted in the following example). 
  140.  
  141. <li>If you define a #set variable that uses a <em>CGI</em> variable
  142. name (say, <tt>PATH_TRANSLATED</tt>), then this #set value will
  143. be used.
  144.  
  145. <li><b>Technical note:</b> SRE-http stores #set variables in the
  146. GLOBAL. stem, using a tail name of <tt>!varname</tt> (that is, preface
  147. the <tt>varname</tt> with a <tt>!</tt>).  
  148. You can reference, or define, these variables in <TT>INTERPRET</tt>
  149. <em>SRE-http style SSIs</em>.
  150.  <blockquote><em>For example, </em>, the following are equivalent:<br>
  151.  
  152. <code> <!-- #set var="monster" value="ghost" --> <br>
  153. <!-- interpret code globals.!MONSTER="ghost" --> 
  154.  
  155. <!--  interpret code GLOBALS.!MONSTER="wolf" -->
  156. <!-- x #set var="monster" value="gho3st" -> 
  157. <br>Monster= <!--  #echo var="monster" -->
  158.  
  159. </blockquote>
  160. </menu>
  161.  
  162. <b>EXAMPLE:</b> the below example will print "in foo" if the DOCUMENT_URI is 
  163. /foo/file.html, "in bar" if it is /bar/file.html and "in neither" 
  164. otherwise:
  165. <PRE>
  166.     <!--#if expr="\"$DOCUMENT_URI\" = \"/foo/file.html\"" -->
  167.     in foo
  168.     <!--#elif expr="\"$DOCUMENT_URI\" = \"/bar/file.html\"" -->
  169.     in bar
  170.     <!--#else -->
  171.     in neither
  172.     <!--#endif -->
  173. </PRE>
  174.  
  175.  
  176. <a href="http://www.apache.org/docs/mod/mod_include.html">Need more
  177. information on the Apache XSSI syntax?</a>
  178.  
  179. </body>
  180. </html>
  181.