Here goes nothing...

Attached are some examples for a proposed format for an xml version of the
module docs along with an Anakia vsl file to transform it to html and an
example of the resulting html.

I am mostly interested in feedback on the xml format.

Some things I don't care about right now:

1. Critiques of the resulting html.  The html can obviously be beautified
considerably, and we will hash that out later.

2. Arguing with anyone about the best xml->html transformation tool.  At the
moment I'm most familiar with Anakia, so that's what I'm using.  If other
people have other preferences, feel free to supply the transformation tools.

3. A DTD.  Actually, I'd love to have one, but I'm not going to spend the
time to figure it
out right now, since the tools to actually use them are so lame.

4. The non-module docs.  We can work that out later.

To integrate this with the existing docs with the least amount of hassle, I
suggest transforming "in place".  That is, the xml files would live in the
same directory as the html files.  I would need to commit the .vsl file and
some build scripts to httpd-2.0/docs/manual/.  We probably wouldn't want to
commit the .jar files, but we could keep them in an easily accessible place.

So what I want to know is:
1. Is there a basic buy-in that this is the correct direction to go?
2. Does anyone have major concerns or suggestions about the xml format?  The
only things that I can think of adding right now are some inline elements
like <modulename> and <directivename>.

Conditional on the answers to those two, we can take this discussion over to
[EMAIL PROTECTED] to hash out the details.

Joshua.
##
## Content Stylesheet for httpd-docs
##
## Defined variables
##
##    
## Start and end the processing
##
#module()
##
## This is where the macros live
##
##


#macro ( make_note $note)
<table border="1" cellpadding="5"><tr><td>
#processtext($note)
</tr></td></table>
#end

#macro (block_example $example)
#if ($example.getChild("title"))
#set ($heading = $example.getChildText("title"))
#else
#set ($heading = "")
#end
<table width="100%" bgcolor="#E0E0F0">
<tr><td><strong><p align="center">$heading</strong></td></tr>
<tr><td><code>

$example
</code></td></tr>
</table>
#end

#macro ( section $section $level )
#if ($section.getChild("title"))
#set ($heading = $section.getChildText("title"))
#elseif ($section.getAttributeValue("id"))
#set ($heading = $section.getAttributeValue("id"))
#else
#set ($heading = "")
#end
<h2>
#if ($section.getAttributeValue("id"))
   <a name="$section.getAttributeValue("id")">$heading</a>
#else
   $heading
#end
</h2>
## Output the section-level children with transformers
#foreach ( $items in $section.getChildren() )
#if ($items.getName().equals("note"))
#make_note ($items)
#elseif ($items.getName().equals("section"))
#set ($sublevel = $level + 1)
#section ($items $sublevel)
#elseif ($items.getName().equals("title"))
## we already handled this one
#else
$items
#end
#end
#end

#macro (processtext $text)
#foreach ( $items in $text.getChildren() )
#if ($items.getName().equals("note"))
#make_note($items)
#elseif ($items.getName().equals("blockexample"))
#block_example($items)
#else
$items
#end
#end
#end

#macro (directive $thedirective $modulename $status)
<h2><a name="$thedirective.getChild("name").getText()" 
id="$thedirective.getChild("name").getText()">
$thedirective.getChild("name").getText() directive</h2>
<table bgcolor="#cccccc" border="0" cellspacing="0" cellpadding="1">
<tr><td>
<table bgcolor="#ffffff" width="100%">
<tr><td><strong>Description:</strong> 
</td><td>$thedirective.getChild("description")</td></tr>
<tr><td><strong><a href="directive-dict.html#Syntax">Syntax:</a></strong> 
</td><td>$thedirective.getChild("syntax")</td></tr>
<tr><td><strong><a href="directive-dict.html#Default">Default:</a></strong> 
</td><td>$thedirective.getChild("default")</td></tr>
<tr><td><strong><a href="directive-dict.html#Context">Context:</a></strong> 
</td><td>$thedirective.getChild("context")</td></tr>
<tr><td><strong><a href="directive-dict.html#Override">Override:</a></strong> 
</td><td>$thedirective.getChild("override")</td></tr>
<tr><td><strong><a href="directive-dict.html#Status">Status:</a></strong> 
</td><td>$status</td></tr>
<tr><td><strong><a href="directive-dict.html#Module">Module:</a></strong> 
</td><td>$modulename</td></tr>
<tr><td><strong><a 
href="directive-dict.html#Compatibility">Compatibility:</a></strong> 
</td><td>$thedirective.getChild("compatibility")</td></tr>
</table>
</td></tr></table>
#processtext($thedirective.getChild("usage"))
#end


#macro ( module )
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
  <head>
    <title>$root.getChild("name").getText() - Apache HTTP Server</title>
 </head>
 <body>        
    <div align="CENTER">
      <img src="../images/sub.gif" alt="[APACHE DOCUMENTATION]" /> 
      <h3>Apache HTTP Server Version 2.0</h3>
    </div>

<h1 align="center">Apache Module $root.getChild("name").getText()</h1>
<div align="center">
<table width="90%" border="0">
<tr><td>
<div align="left">
<p>$root.getChild("description").getText()</p>
<table bgcolor="#cccccc" cellpadding="0" cellspacing="1">
<tr><td>
<table bgcolor="#ffffff">
<tr><td><strong><a href="module-dict.html#Status">Status:</a></strong> 
</td><td>$root.getChild("status").getText()</td></tr>
<tr><td><strong><a href="module-dict.html#ModuleIdentifier">Module 
Identifier:</a></strong> 
</td><td>$root.getChild("identifier").getText()</td></tr>
</table>
</td></tr>
</table>
<h2>Summary</h2>
#processtext($root.getChild("summary"))
<h2>Directives</h2>
<ul>
#set ($alldirectives = $root.getChildren("directive"))
#foreach ($directive in $alldirectives)
<li><a 
href="#$directive.getChild("name").getText()">$directive.getChild("name").getText()</li>
#end
</ul>
#set ($allSections = $root.getChild("module").getChildren("section"))
#foreach ( $section in $allSections )
  #section ($section 1)
#end
<hr />
#foreach ($directive in $alldirectives)
  #directive ($directive $root.getChild("name").getText() 
$root.getChild("status").getText())
<div align="center">
<hr noshade="noshade" width="75%"/>
</div>
<br /><br />
#end
    <h3 align="CENTER">Apache HTTP Server Version 2.0</h3>
    <a href="./"><img src="../images/index.gif" alt="Index" /></a>
    <a href="../"><img src="../images/home.gif" alt="Home" /></a>
</div></td></tr>
</table>
</div>
</body>
</html>
#end
Title: mod_setenvif - Apache HTTP Server
[APACHE DOCUMENTATION]

Apache HTTP Server Version 2.0

Apache Module mod_setenvif

Allows the setting of environment variables based on characteristics of the request

Status: Base
Module Identifier: setenvif_module

Summary

The mod_setenvif module allows you to set environment variables according to whether different aspects of the request match regular expressions you specify. These environment variables can be used by other parts of the server to make decisions about actions to be taken.

The directives are considered in the order they appear in the configuration files. So more complex sequences can be used, such as this example, which sets netscape if the browser is mozilla but not MSIE.

BrowserMatch ^Mozilla netscape
BrowserMatch MSIE !netscape

For additional information, we provide a document on Environment Variables in Apache.

Directives


BrowserMatch directive

Description: Sets environment variables conditional on HTTP User-Agent
Syntax: BrowserMatch regex env-variable[=value] [env-variable[=value]] ...
Default: none
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_setenvif
Compatibility: Apache 1.2 and above (in Apache 1.2 this directive was found in the now-obsolete mod_browser module)

The BrowserMatch directive defines environment variables based on the User-Agent HTTP request header field. The first argument should be a POSIX.2 extended regular _expression_ (similar to an egrep-style regex). The rest of the arguments give the names of variables to set, and optionally values to which they should be set. These take the form of

  1. varname, or
  2. !varname, or
  3. varname=value

In the first form, the value will be set to "1". The second will remove the given variable if already defined, and the third will set the variable to the value given by value. If a User-Agent string matches more than one entry, they will be merged. Entries are processed in the order in which they appear, and later entries can override earlier ones.

For example:

BrowserMatch ^Mozilla forms jpeg=yes browser=netscape
BrowserMatch "^Mozilla/[2-3]" tables agif frames _javascript_
BrowserMatch MSIE !_javascript_

Note that the regular _expression_ string is case-sensitive. For case-INsensitive matching, see the BrowserMatchNoCase directive.

The BrowserMatch and BrowserMatchNoCase directives are special cases of the SetEnvIf and SetEnvIfNoCase directives. The following two lines have the same effect:

BrowserMatchNoCase Robot is_a_robot
SetEnvIfNoCase User-Agent Robot is_a_robot



BrowserMatchNoCase directive

Description: Sets environment variables conditional on User-Agent without respect to case
Syntax: BrowserMatchNoCase regex env-variable[=value] [env-variable[=value]] ...
Default: none
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_setenvif
Compatibility: Apache 1.2 and above (in Apache 1.2 this directive was found in the now-obsolete mod_browser module)

The BrowserMatchNoCase directive is semantically identical to the BrowserMatch directive. However, it provides for case-insensitive matching. For example:

BrowserMatchNoCase mac platform=macintosh
BrowserMatchNoCase win platform=windows

The BrowserMatch and BrowserMatchNoCase directives are special cases of the SetEnvIf and SetEnvIfNoCase directives. The following two lines have the same effect:

BrowserMatchNoCase Robot is_a_robot
SetEnvIfNoCase User-Agent Robot is_a_robot



SetEnvIf directive

Description: Sets environment variables based on attributes of the request
Syntax: SetEnvIf attribute regex env-variable[=value] [env-variable[=value]] ...
Default: none
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_setenvif
Compatibility: Apache 1.3 and above; the Request_Protocol keyword and environment-variable matching are only available with 1.3.7 and later

The SetEnvIf directive defines environment variables based on attributes of the request. These attributes can be the values of various HTTP request header fields (see RFC2616 for more information about these), or of other aspects of the request, including the following:

  • Remote_Host - the hostname (if available) of the client making the request
  • Remote_Addr - the IP address of the client making the request
  • Remote_User - the authenticated username (if available)
  • Request_Method - the name of the method being used (GET, POST, et cetera)
  • Request_Protocol - the name and version of the protocol with which the request was made (e.g., "HTTP/0.9", "HTTP/1.1", etc.)
  • Request_URI - the portion of the URL following the scheme and host portion

Some of the more commonly used request header field names include Host, User-Agent, and Referer.

If the attribute name doesn't match any of the special keywords, nor any of the request's header field names, it is tested as the name of an environment variable in the list of those associated with the request. This allows SetEnvIf directives to test against the result of prior matches.

Only those environment variables defined by earlier SetEnvIf[NoCase] directives are available for testing in this manner. 'Earlier' means that they were defined at a broader scope (such as server-wide) or previously in the current directive's scope.

attribute may be a regular _expression_ when used to match a request header. If attribute is a regular _expression_ and it doesn't match any of the request's header names, then attribute is not tested against the request's environment variable list.

Example:

Example: SetEnvIf Request_URI "\.gif$" object_is_image=gif
SetEnvIf Request_URI "\.jpg$" object_is_image=jpg
SetEnvIf Request_URI "\.xbm$" object_is_image=xbm
:
SetEnvIf Referer www\.mydomain\.com intra_site_referral
:
SetEnvIf object_is_image xbm XBIT_PROCESSING=1
:
SetEnvIf ^TS* ^[a-z].* HAVE_TS

The first three will set the environment variable object_is_image if the request was for an image file, and the fourth sets intra_site_referral if the referring page was somewhere on the www.mydomain.com Web site.

The last example will set environment variable HAVE_TS if the request contains any headers that begin with "TS" whose values begins with any character in the set [a-z].




SetEnvIfNoCase directive

Description: Sets environment variables based on attributes of the request without respect to case
Syntax: SetEnvIfNoCase attribute regex env-variable[=value] [env-variable[=value]] ...
Default: none
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_setenvif
Compatibility: Apache 1.3 and above

The SetEnvIfNoCase is semantically identical to the SetEnvIf directive, and differs only in that the regular _expression_ matching is performed in a case-insensitive manner. For example:

SetEnvIfNoCase Host Apache\.Org site=apache

This will cause the site environment variable to be set to "apache" if the HTTP request header field Host: was included and contained Apache.Org, apache.org, or any other combination.




Apache HTTP Server Version 2.0

Index Home
<?xml version="1.0"?>
<module>

<name>mod_setenvif</name>
<status>Base</status>
<identifier>setenvif_module</identifier>

<description>Allows the setting of environment variables based
on characteristics of the request</description>

<summary>

    <p>The <samp>mod_setenvif</samp> module allows you to set
    environment variables according to whether different aspects of
    the request match regular expressions you specify. These
    environment variables can be used by other parts of the server
    to make decisions about actions to be taken.</p>

    <p>The directives are considered in the order they appear in
    the configuration files. So more complex sequences can be used,
    such as this example, which sets <code>netscape</code> if the
    browser is mozilla but not MSIE.</p>

<blockexample>
  BrowserMatch ^Mozilla netscape<br />
  BrowserMatch MSIE !netscape<br />
</blockexample>

    <p>For additional information, we provide a document on <a
    href="../env.html">Environment Variables in Apache</a>.</p>

</summary>

<directive>
<name>BrowserMatch</name>
<description>Sets environment variables conditional on HTTP User-Agent
</description>
<syntax>BrowserMatch <em>regex env-variable</em>[=<em>value</em>]
[<em>env-variable</em>[=<em>value</em>]] ...</syntax>
<default><i>none</i></default>
<context>server config, virtual host, directory, .htaccess</context>
<override>FileInfo</override>
<compatibility>Apache 1.2 and
    above (in Apache 1.2 this directive was found in the
    now-obsolete mod_browser module)</compatibility>

<usage>
    <p>The BrowserMatch directive defines environment variables
    based on the <samp>User-Agent</samp> HTTP request header field.
    The first argument should be a POSIX.2 extended regular
    expression (similar to an <samp>egrep</samp>-style regex). The
    rest of the arguments give the names of variables to set, and
    optionally values to which they should be set. These take the
    form of</p>

    <ol>
      <li><samp><em>varname</em></samp>, or</li>

      <li><samp>!<em>varname</em></samp>, or</li>

      <li><samp><em>varname</em>=<em>value</em></samp></li>
    </ol>

    <p>In the first form, the value will be set to "1". The second
    will remove the given variable if already defined, and the
    third will set the variable to the value given by
    <samp><em>value</em></samp>. If a <samp>User-Agent</samp>
    string matches more than one entry, they will be merged.
    Entries are processed in the order in which they appear, and
    later entries can override earlier ones.</p>

    <p>For example:</p>
<blockexample>
    BrowserMatch ^Mozilla forms jpeg=yes browser=netscape<br />
    BrowserMatch "^Mozilla/[2-3]" tables agif frames javascript<br />
    BrowserMatch MSIE !javascript<br />
</blockexample>
 
    <p>Note that the regular expression string is
    <strong>case-sensitive</strong>. For case-INsensitive matching,
    see the <a
    href="#BrowserMatchNoCase"><samp>BrowserMatchNoCase</samp></a>
    directive.</p>

    <p>The <samp>BrowserMatch</samp> and
    <samp>BrowserMatchNoCase</samp> directives are special cases of
    the <a href="#SetEnvIf"><samp>SetEnvIf</samp></a> and <a
    href="#SetEnvIfNoCase"><samp>SetEnvIfNoCase</samp></a>
    directives. The following two lines have the same effect:</p>
<blockexample>
   BrowserMatchNoCase Robot is_a_robot<br />
   SetEnvIfNoCase User-Agent Robot is_a_robot<br />
</blockexample>
</usage>
</directive>

<directive>
<name>BrowserMatchNoCase</name>
<description>Sets environment variables conditional on User-Agent without
respect to case</description>
<syntax>BrowserMatchNoCase  <em>regex env-variable</em>[=<em>value</em>]
    [<em>env-variable</em>[=<em>value</em>]] ...</syntax>
<default><em>none</em></default>
<context>server config, virtual host, directory, .htaccess</context>
<override>FileInfo</override>
<compatibility>Apache 1.2 and
    above (in Apache 1.2 this directive was found in the
    now-obsolete mod_browser module)</compatibility>

<usage>

    <p>The <samp>BrowserMatchNoCase</samp> directive is
    semantically identical to the <a
    href="#BrowserMatch"><samp>BrowserMatch</samp></a> directive.
    However, it provides for case-insensitive matching. For
    example:</p>
<blockexample>
    BrowserMatchNoCase mac platform=macintosh<br />
    BrowserMatchNoCase win platform=windows<br />
</blockexample>

    <p>The <samp>BrowserMatch</samp> and
    <samp>BrowserMatchNoCase</samp> directives are special cases of
    the <a href="#SetEnvIf"><samp>SetEnvIf</samp></a> and <a
    href="#SetEnvIfNoCase"><samp>SetEnvIfNoCase</samp></a>
    directives. The following two lines have the same effect:</p>
<blockexample>
   BrowserMatchNoCase Robot is_a_robot<br />
   SetEnvIfNoCase User-Agent Robot is_a_robot<br />
</blockexample>
</usage>
</directive>

<directive>
<name>SetEnvIf</name>
<description>Sets environment variables based on attributes of the request
</description>
<syntax>SetEnvIf <em>attribute
    regex env-variable</em>[=<em>value</em>]
    [<em>env-variable</em>[=<em>value</em>]] ...</syntax>
<default><em>none</em></default>
<context> server config, virtual host, directory, .htaccess</context>
<override>FileInfo</override>
<compatibility>Apache 1.3 and
    above; the Request_Protocol keyword and environment-variable
    matching are only available with 1.3.7 and later</compatibility>

<usage>
    <p>The <samp>SetEnvIf</samp> directive defines environment
    variables based on attributes of the request. These attributes
    can be the values of various HTTP request header fields (see <a
    href="http://www.rfc-editor.org/rfc/rfc2616.txt";>RFC2616</a>
    for more information about these), or of other aspects of the
    request, including the following:</p>

    <ul>
      <li><samp>Remote_Host</samp> - the hostname (if available) of
      the client making the request</li>

      <li><samp>Remote_Addr</samp> - the IP address of the client
      making the request</li>

      <li><samp>Remote_User</samp> - the authenticated username (if
      available)</li>

      <li><samp>Request_Method</samp> - the name of the method
      being used (<samp>GET</samp>, <samp>POST</samp>, <em>et
      cetera</em>)</li>

      <li><samp>Request_Protocol</samp> - the name and version of
      the protocol with which the request was made (<em>e.g.</em>,
      "HTTP/0.9", "HTTP/1.1", <em>etc.</em>)</li>

      <li><samp>Request_URI</samp> - the portion of the URL
      following the scheme and host portion</li>
    </ul>

    <p>Some of the more commonly used request header field names
    include <samp>Host</samp>, <samp>User-Agent</samp>, and
    <samp>Referer</samp>.</p>

    <p>If the <em>attribute</em> name doesn't match any of the
    special keywords, nor any of the request's header field names,
    it is tested as the name of an environment variable in the list
    of those associated with the request. This allows
    <code>SetEnvIf</code> directives to test against the result of
    prior matches.</p>

<note>
      <strong>Only those environment variables defined by earlier
      <code>SetEnvIf[NoCase]</code> directives are available for
      testing in this manner. 'Earlier' means that they were
      defined at a broader scope (such as server-wide) or
      previously in the current directive's scope.</strong>
</note>

    <p><em>attribute</em> may be a regular expression when used to
    match a request header. If <em>attribute</em> is a regular
    expression and it doesn't match any of the request's header
    names, then <em>attribute</em> is not tested against the
    request's environment variable list.</p>

<blockexample>
<title>Example:</title>
   SetEnvIf Request_URI "\.gif$" object_is_image=gif<br />
   SetEnvIf Request_URI "\.jpg$" object_is_image=jpg<br />
   SetEnvIf Request_URI "\.xbm$" object_is_image=xbm<br />
        :<br />
   SetEnvIf Referer www\.mydomain\.com intra_site_referral<br />
        :<br />
   SetEnvIf object_is_image xbm XBIT_PROCESSING=1<br />
        :<br />
   SetEnvIf ^TS*  ^[a-z].*  HAVE_TS<br />
</blockexample>

    <p>The first three will set the environment variable
    <samp>object_is_image</samp> if the request was for an image
    file, and the fourth sets <samp>intra_site_referral</samp> if
    the referring page was somewhere on the
    <samp>www.mydomain.com</samp> Web site.</p>

    <p>The last example will set environment variable
    <samp>HAVE_TS</samp> if the request contains any headers that
    begin with "TS" whose values begins with any character in the
    set [a-z].</p>
</usage>
</directive>

<directive>
<name>SetEnvIfNoCase</name>
<description>Sets environment variables based on attributes of the request
without respect to case</description>
<syntax>SetEnvIfNoCase <em>attribute regex env-variable</em>[=<em>value</em>]
    [<em>env-variable</em>[=<em>value</em>]] ...</syntax>
<default><em>none</em></default>
<context>server config, virtual host, directory, .htaccess</context>
<override>FileInfo</override>
<compatibility>Apache 1.3 and above</compatibility>

<usage>

    <p>The <samp>SetEnvIfNoCase</samp> is semantically identical to
    the <a href="#SetEnvIf"><samp>SetEnvIf</samp></a> directive,
    and differs only in that the regular expression matching is
    performed in a case-insensitive manner. For example:</p>
<blockexample>
   SetEnvIfNoCase Host Apache\.Org site=apache
</blockexample>

    <p>This will cause the <samp>site</samp> environment variable
    to be set to "<samp>apache</samp>" if the HTTP request header
    field <samp>Host:</samp> was included and contained
    <samp>Apache.Org</samp>, <samp>apache.org</samp>, or any other
    combination.</p>
</usage>
</directive>
</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to