Skip to main content

An extensible HTML/XML generator

Project description

XIST is an extensible HTML and XML generator. XIST is also a XML parser 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 XSLT’.

Changes in 3.0 (released 01/07/2008)

  • Namespaces have been greatly simplified. There are no namespace modules any longer. An element class can be assigned a namespace by setting the xmlns class attribute to the namespace name. Global attributes can be assigned a namespace by setting the xmlns attribute on the attribute class itself (not on the Attrs class). The classes Prefixes and NSPool are gone too. Instead a new class Pool is used to specify which classes should be used for parsing.

  • Dependency on PyXML has finally been dropped. XIST now uses its own XML parsing API. Two parsers are available: One based on expat and one based on a custom version of sgmlop.

  • Tree traversal has been rewritten again. XFind expressions involving multiple uses of // now work correctly. The method walk now doesn’t yield Cursor objects, but simple path lists (actually it’s always the same list, if you want distinct lists use walkpath). Applying XFind expressions to nodes directly is no longer supported, you have to call walk, walknode or walkpath with the XFind expression instead. Many XFind operators have been renamed and/or reimplemented (see the documentation for the xfind module for more information).

  • The methods __getitem__, __setitem__ and __delitem__ for Frag and Element now support the new walk filters, so you can do:

    • del node[html.p] to delete all html.p child elements of node;

    • del node[html.p[2]] to delete only the third html.p;

    • node[xfind.hasclass("note")] = html.p("There was a note here!") to replace several child nodes with a new one;

    • for c in node[xfind.empty]: print c.bytes() to print all empty (element) children of node;

    • del node[node[0]] to delete the first child node (which is silly, but illustrates that you can pass a node to get/replace/delete that node);

  • A new module ll.xist.css has been added which contains CSS related functionality: The generator function iterrules can be passed an XIST tree and it will produce all CSS rules defined in any html.link or html.style elements or imported by them (via the CSS rule @import). This requires the cssutils package.

  • The function applystylesheets modifies the XIST tree passed in by removing all CSS (from html.link and html.style elements and their @import``ed stylesheets) and putting the styles into ``style attributes of the affected elements instead.

  • The function selector returns a tree walk filter from a CSS selector passed as a string.

  • Constructing trees can now be done with with blocks. Code looks like this:

    with xsc.Frag() as node:
            +xml.XML()
            +html.DocTypeXHTML10transitional()
            with html.html():
                    with html.head():
                            +meta.contenttype()
                            +html.title("Example page")
                    with html.body():
                            +html.h1("Welcome to the example page")
                            with html.p():
                                    +xsc.Text("This example page has a link to the ")
                                    +html.a("Python home page", href="http://www.python.org/")
                                    +xsc.Text(".")
    
    print node.conv().bytes(encoding="us-ascii")

    Also the function xsc.append has been renamed to add and supports with blocks now instead of XPython.

  • A subset of ReST is supported now for docstrings when using the ll.xist.ns.doc module. The module attribute __docformat__ is now honored (Set it to "xist" to get XIST docstrings).

  • Many classes in the ll.xist.ns.doc have been renamed to more familiar names (from HTML, XHTML 2 or ReST).

  • The media attribute of html.link and html.style now has a method hasmedia.

  • The node method asBytes has been renamed to bytes and bytes has been renamed to iterbytes.

  • The node method asString has been renamed to string and a new method iterstring has been added.

  • ll.xist.ns.xml.XML10 is gone now. Use ll.xist.ns.xml.XML instead.

  • xsc.tonode now will raise an exception when it can’t handle an argument instead of issuing a warning.

  • A class attribute empty inside element classes will now no longer get converted into model.

  • ll.xist.ns.doc.pyref now copes better with decorated methods.

  • The deprecated Element methods hasAttr, hasattr, isallowedattr, getAttr, getattr, setDefaultAttr, setdefaultattr, attrkeys, attrvalues, attritems, iterattrkeys, iterattrvalues, iterattritems, allowedattrkeys, allowedattrvalues, allowedattritems, iterallowedattrkeys, iterallowedattrvalues, iterallowedattritems and copyDefaultAttrs have been removed. The deprecated Attrs method copydefaults has been removed too.

  • The namespace module ll.xist.ns.cond has been removed.

  • When calling the function ll.xist.parsers.parseURL the arguments headers and data are now passed along to the parser’s method only if they are specified. This makes it possible to pass ssh URLs to ll.xist.parsers.parseURL.

  • The methods withnames and withoutnames have been split into two that take Python names and two that take XML names. Multiple arguments are used now (instead of one argument that must be a sequence). Passing a namespace to remove all attributes from the namespace is no longer supported.

  • The Attrs methods updatenew and updatexisting have been removed.

Project details


Release history Release notifications | RSS feed

This version

3.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

ll-xist-3.0.zip (310.1 kB view hashes)

Uploaded Source

ll-xist-3.0.tar.gz (259.5 kB view hashes)

Uploaded Source

ll-xist-3.0.tar.bz2 (209.7 kB view hashes)

Uploaded Source

Built Distributions

ll_xist-3.0-py2.5-linux-i686.egg (552.5 kB view hashes)

Uploaded Source

ll-xist-3.0.win32-py2.5.exe (302.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page