Example Programs and Demos for 4XSLT
====================================

Command Line Basics
-------------------

Change to the 4XSLT demo directory where your 4Suite documents were installed.

The most basic usage of 4XSLT is simply

% 4xslt addr_book1.xml

You should get an HTML document printed to the screen.  this is the result
of the XSLT transform.

Notice that you didn't specify the transform file (stylesheet".  This is
because the file addr_book1.xml contains the processing instruction

<?xml-stylesheet href="addr_book1.xsl" type="text/xml"?>

in the prolog, which tells 4XSLT to use the addr_book1.xsl transform.

You can explicitly specify the transform as follows

% 4xslt -i addr_book1.xml addr_book1.xsl

The "-i" option tells 4XSLT to ignore the stylesheet processing instructions
in the source document.

Of course, then you're free to use whatever transform you like

% 4xslt -i addr_book1.xml addr_book2.xsl

Notice the subtle differences in the output.  The only difference between
addr_book1.xsl and addr_book2.xsl is that the latter adds the lines

  <!-- Generate XHTML -->
  <xsl:output method="xml"/>

Since addr_book1.xsl had no xsl:output instruction, it defaulted to HTML
method since the first element output was named "html".

addr_book2.xsl forces XML output method and you can see the differences.
The output isn't prettily indented, the empty "br" tags are rendered
as "<br/>" rather than "br>", and there is no <META> HTML header for
character set and encoding.

To use a validating parser for reading in the source document, there
is the "-v" (validate) option.

% 4xslt -v addr_book2.xml

If you examine addr_book2.xml, you'll see that the content model is specified
in the internal DTD subset.  If you were to change the document instance to
violate the content model (for instance add a bogus element), you would
get validation errors.

Notice that all output so far has gone to the console.  Perhaps you
want to write the output to file.  One way to do this is using standard
redirection

% 4xslt addr_book1.xml > output.html

But this might not always be convenient.  You can also use the "-o" option
to specify an output file

% 4xslt -o output.html addr_book1.xml

Finally, perhaps you don't want to read the source document from a file.
Maybe you want to read content piped in from another program, or even
type in the source right on the command line (if you're feeling brave).

In this case you can use "-" as the source file name

% 4xslt - < addr_book1.xml


Using the 4XSLT API
-------------------

The python files in the demo directory demonstrate using 4XSLT's programming
API so that your own Python programs can take advantage of 4XSLT


*  merry_xmas.py is a little toy that generates and prints out a Christmas
   tree using asterisks.


*  mime_example.py is a bit more practical.  It takes an XML format
   representing an e-mail message and generates a MIME-compliant e-mail
   message.  For good measure it actually sends the message to
   'bitbucket@dev.null'.  Of course, since this e-mail address is bogus,
   you'll probably get an e-mail bounce message.  If you'd rather send to
   an actual e-mail address, place it on the command line, for example
   "python mime_example.py president@whitehouse.gov"

