Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install compactxml

How to install compactxml

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install compactxml
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
2.1.0 Available View build log
2.0.3 Available View build log
Windows (64-bit)
2.1.0 Available View build log
2.0.3 Available View build log
Mac OS X (10.5+)
2.1.0 Available View build log
2.0.3 Available View build log
Linux (32-bit)
2.1.0 Available View build log
2.0.3 Available View build log
Linux (64-bit)
2.1.0 Available View build log
2.0.3 Available View build log
 
Author
License
GPL v2
Dependencies
Imports
Lastest release
version 2.1.0 on Feb 7th, 2011

Summary

Compact XML is an alternative syntax for representing XML files. It uses indentation to indicate nesting to give a python like feel, XPath based prefixes to identify nodes, and has a macro system to shorten common XML constructs. It is intended for writing element based XML files, especially those where the XML elements share a common structure such as XSLT files.

This package includes a parser and bidirectional converter for converting from this compact XML syntax to XML, and from XML to this compact XML syntax.

Why Do I Want This?

Unlike most projects to create a shorter XML, compact XML is not designed for compressing XML on the wire. Instead, this syntax is designed to make editing XML easier with common editors, and to provide a convenient, configurable shorthand when authoring XML documents with a common syntax.

If you spend all day writing XSLT files or something similar, this will let you work with source files that look like this:

xsl:stylesheet
        xsl:output xml no

        xsl:template "@* | node( )"
                xsl:copy
                        xsl:apply-templates "@* | node( )"

Instead of like this:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no"/>

<xsl:template match="@* | node( )">
        <xsl:copy>
                <xsl:apply-templates select="@* | node( )"/>
        </xsl:copy>
</xsl:template>

</xsl:stylesheet>

If you're integrating with a python based program, the parser can be built in and parse compact XML files to XML directly. Otherwise a simple command line utility is included that can be used inside make or equivalent to convert to XML as part of your build process.

Install

compactxml is a pure python library, and should be platform independent. It has been developed and tested on python 2.6 on linux, however. As dependencies, it requires that lxml and pyparsing be installed to function.

A normal python setup.py install command should work to install the library.

Usage

There is a compactxml.expand function for converting from compact XML syntax to XML, and a compactxml.compact function for converting from XML to compact XML syntax, with variations on both depending on the output format desired. help( compactxml ) will give better usage instructions, and the included documentation in compactxml.rst provides a comprehensive overview of the compact xml syntax.

Any errors in expansion or compaction are raised as compactxml.ParsingError.

There is also a command line utility compactxml.py in the source distribution which can be used for converting from/to compact xml syntax. See compactxml.py --help for usage information after installation.

Documentation

Detailed documentation of the compact XML format is available through the python package index, including a tutorial for new users.

Subscribe to package updates

Last updated Feb 7th, 2011

Download Stats

Last month:3

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.