xhtmlDir v0.1a by Moritz Ringler


xhtmlDir is a fully and easily configurable perl script for generating directory lists in XHMTL, the XML-compatible version of HTML. As the program is written in Perl you dispose of the whole power of Perl regular expressions to choose the files you want to list (see the --include and --exclude options below).
sample list


Both files have the same contents. (Browse contents here.)
xhtmldir.tar.bz2bzipped tar archive
xhtmldir.zipzip archive


To run this program you will need a Perl interpreter. For more information on Perl and how to obtain it see:

http://www.perl.orgThe Perl mongers home page
http://www.ActiveState.comThe ActiveState home page
You should also make sure that the following modules are installed (in brackets the CPAN packages that I use).
XML::Simple(XML-Simple-1.08 by Grant McLean)
XML::Generator(XML-Generator-0.91 by Benjamin Holzman) !needs 0.91 or later!
URI::Escape(URI-1.22 by Gisle Haas)
Getopt::Long(Getopt-Long-2.32 by Johan Vromans)
Cwd(Cwd-3.05 by Ken Williams)
Date::Format(TimeDate-1.14 by Graham Barr)
Unicode::String(Unicode-String-2.06 by Gisle Aas)

Most of these packages should be included in your perl distribution. The file installpackages.html, which I found at
describes how you can get and install missing modules. You might need to tell ppm to use some more "package repositories" besides the two repositories that are activated by default.


There are two ways of adapting the configuration to your needs:
1) by specifying command line options (see help text below or call the script with the --help option.
2) by editing the XML-configuration file (make a backup copy before you do) This should be pretty straightforward as the tag and attribute names of the configuration file are chosen to be self-explanatory.
Furthermore you can completely change the look and feel of the output you get if you tell the program to use your own tailor-made CSS-stylesheet. As a simple way to create your own styles you might take the default stylesheet (either from the perl source code or from the enclosed file default.css) and modify it according to your needs.

synopsis and command line options

  * xhtmldir: configurable generator for XHTML directory lists
  * USAGE: perl xhtmldir.pl [OPTIONS] rootdir
  *     rootdir               directory to list
  *                           default: current directory
  *     --help                print this usage information and exit
  *     --sort_by=name|ext|ftype|size|date[-]
  *                           sort files by specified attribute
  *                           append '-' to sort in descending order
  *                           default: name
  *     --tree_depth=N        maximum subdirectory level
  *                           default: 0
  *     --stdout              print xml to standard output
  *     --output=FILE         print xml to FILE, overrides --stdout
  *                           default: xhtmldir.html
  *     --cfg=FILE            load configuration from FILE
  *                           default: config.xml in the same directory
  *                           as the program file
  *     --css=FILE            use specified CSS FILE instead of default layout
  *     --base_href=URI|DIR   address base for xml output
  *                           default: rootdir
  *     --icon_repository=URI|DIR
  *                           address base for icon files
  *                           default: base_href
  *     --include=REGEXP      include only files whose name  matches  the
  *                           Perl RegExp REGEXP, e.g. /txt$/i; see note
  *                           on regular expressions below
  *     --exclude=REGEXP      exclude files that match REGEXP; if a filename
  *                           matches both include and exclude it is not
  *                           listed; see note on regular expressions below
  *     --target=NAME         sets the link target window/frame to NAME
  * Options may be abbreviated to uniqueness. All options except 'cfg' can be
  * given different default values by specifying attributes to the <config />
  * tag in the configuration file.
  * Note on regular expressions: Depending on the terminal/shell you use
  * some of the special characters that are so frequent in Perl regular
  * expressions might have to be escaped in order to be interpreted as an
  * ordinary letter on the command line. You might try:
  * double quotes ("--exclude=/^x/") [CMD.EXE, COMMAND.COM]
  * single quotes ('--include=/txt$/') [tcsh]
  * backslash (--include=/txt\$/) [tcsh]