[XML-SIG] ANN: XIST 1.0
Walter Dörwald
walter@livinglogic.de
Mon, 18 Jun 2001 14:15:48 +0200
XIST 1.0 has been released!
What is it?
===========
XIST is an XML based extensible HTML generator written in Python. XIST
is also a DOM parser (built on top of SAX2) with a very simple and
pythonesque tree API. Every XML element type corresponds to a Python
class and these Python classes provide a conversion method to transform
the XML tree (e.g. into HTML). XIST can be considered "object oriented
XSL".
Some of the significant features of XIST include:
* Easily extensible with new XML elements,
* Can be used for offline or online page generation,
* Allows embedding Python code in XML files,
* Supports separation of layout and logic,
* Can be used together with mod_python, PyWX or Webware to generate
dynamic pages,
* Fully supports Unicode,
* Provides features to use XIST together with JSP/struts,
* Simplifies handling of deeply nested directory trees,
* Automatically generates HEIGHT and WIDTH attributes for images.
XIST was written as a replacement for the HTML preprocessor HSC, and
borrows some features and ideas from it.
It also borrows the basic ideas (XML/HTML elements as Python objects)
from HTMLgen and HyperText.
What's new in version 1.0?
==========================
A lot!
* New module for WML 1.3.
* There is now a tool dtd2xsc.py in the scripts directory that
creates a skeleton XIST module from a DTD (this requires xmlproc
from the PyXML package).
* New preliminary module for DocBook 4.12. (Incomplete: convert
methods and Unicode character entities are missing; any volunteers
for implementing 375 classes?)
* New module ruby.py that implements the W3C Ruby draft.
* New namespace modules ns/jsp.py and ns/struts_html.py have been
added that allow you to use JSP and Struts tags with XIST.
* A new method asText was added, that returns the node as a formatted
plain ASCII text (this requires that w3m is installed.)
* sql.py has been removed from XIST, but is available as a separate
module.
* All the asHTML methods now have an additional argument converter.
This makes it possible to implement different processing modes or
stages for new elements. All currently implemented elements and
entities ignore this argument, but pass it on in the call to their
childrens' asHTML method. As the name asHTML no longer makes sense,
asHTML has been renamed to convert.
* The parsing interface has been changed. Parsing is now done with
the functions parseFile, parseString, parseURL and parseTidyURL in
the module parsers. It's now possible to specify which parser
should be used for parsing by passing a SAX2 parser instance to any
of these functions. XIST now includes a rudimentary SAX2 driver for
sgmlop and a rudimentary HTML parser that emits SAX2 events.
* The python-quotes example has been updated to work with expat.
* Added a new example: media.
* The publishing interface has changed internally and publishing
should be faster now.
* Publishers now support a new parameter: usePrefix, which specifies
if namespace prefixes should be output for the element names.
* Part of the implementation of the publishing stuff has been moved
to C, so now you'll need a C compiler to install XIST.
* When publishing ", it will now only be replaced with " inside
attributes.
* All abbreviation entities have been moved to a new module abbr.py.
* All the modules that provide new elements and entitites have been
moved to a subpackage ns.
* Frag and Element now have new methods sorted, reversed, filtered
and shuffled that return sorted, reversed, filtered and shuffled
versions of the Frag/Element object.
* make.py has been renamed to xscmake.py and moved to the scripts
directory, it will be installed as a callable script with python
setup.py install_scripts.
* xscmake.py has a new option --files/-f. The argument is a file
containing a list of filenames (one name per line) that should be
converted.
* xscmake.py has a new option -r/--parser for specifying which parser
to use. Allowed values are sgmlop and expat.
* xscmake.py has a new option -n/--namespace that can be used for
appending Namespace objects to the Namespaces object used by
xscmake.py.
xscmake.py -n html -n spam eggs.xsc
With this call the parser will find element classes from the module
with the prefix name spam before those from html and those before
anything else.
* xist.url.URL no longer has an attribute ext. file and ext are
merged.
* The special treatment of sequences as constructor arguments to Frag
and Element has be removed, so XIST will no longer remove one level
of nesting. If you still want that, use a * argument.
* Frag and Element now have a new method mapped, that recursively
maps the nodes through a function. This is like convert but via an
external function.
* Attribute handling has been improved thanks to a suggestion by
Hartmut Goebel: Element.__getitem__ now always works as long as the
attribute name is legal. If the attribute is not set, an empty
attribute will be returned. All empty attributes will be considered
as being not set and so hasAttr returns 0 for them, and publish
doesn't publish them. This simplifies several very common cases:
1. Copying an attribute from one element to another works
regardless of whether the attribute is set or not;
2. Testing for an attributes presence can now be done much
simpler: if element["attrname"] instead of if element.hasAttr
("attrname") (which still works, and should be a little
faster);
3. When you construct a DOM tree and the presence or absence of an
attribute is tied to a condition, you can construct the
attribute in advance and use it afterwards in the tree
construction:
if condition:
align = "right"
else:
align = None
node = html.div("spam", align=align)
So, when the condition is false, the node will not have the
attribute align set.
* xist.ns.cond.If (and xist.ns.cond.ElIf) can now be used to test for
attributes of the converter. I.e. it's possible to write the
following XML:
<if lang="en">Title
<elif lang="de">Überschrift
</if>
* URL handling has be completely changed and is much, much simpler
now. There are no more path markers. To specify an URL that is
relative to the current directory use the scheme root (e.g. root:
main.css).
Where can I get it?
===================
XIST can be downloaded from ftp://titan.bnbt.de/pub/livinglogic/xist/
Web pages are at http://www.livinglogic.de/Python/xist/
Bye,
Walter Dörwald