Skip to main content

Parser and converter for an alternate compact XML syntax.

Project description

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.

Project details


Download files

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

Source Distributions

compactxml-2.1.0.zip (88.6 kB view details)

Uploaded Source

compactxml-2.1.0.tar.gz (73.0 kB view details)

Uploaded Source

Built Distributions

compactxml-2.1.0.win32.exe (220.6 kB view details)

Uploaded Source

compactxml-2.1.0-py2.7.egg (50.3 kB view details)

Uploaded Egg

File details

Details for the file compactxml-2.1.0.zip.

File metadata

  • Download URL: compactxml-2.1.0.zip
  • Upload date:
  • Size: 88.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for compactxml-2.1.0.zip
Algorithm Hash digest
SHA256 cbca2c48fde0ce2fb2ceb4206ba4a08db45887b4c5ed98133b2e3c992032f695
MD5 6ff936f8e35b7f031d0f6714ca70f7f6
BLAKE2b-256 55afc4ca41c7d55bcd80ed6e89e9b8876f180c2a9c2aeaf3e5962c04823fcd5f

See more details on using hashes here.

File details

Details for the file compactxml-2.1.0.tar.gz.

File metadata

  • Download URL: compactxml-2.1.0.tar.gz
  • Upload date:
  • Size: 73.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for compactxml-2.1.0.tar.gz
Algorithm Hash digest
SHA256 75cf5eac875aa7618eead7365fb505470cb04bbb8d785b725b985f33caf41761
MD5 06e6ce63fd131695a9cb89c45fafc18c
BLAKE2b-256 beef39f4a0fced38afd005a4972c92f5bb97f7b434fe251752bc169033ad334d

See more details on using hashes here.

File details

Details for the file compactxml-2.1.0.win32.exe.

File metadata

  • Download URL: compactxml-2.1.0.win32.exe
  • Upload date:
  • Size: 220.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for compactxml-2.1.0.win32.exe
Algorithm Hash digest
SHA256 dbb54fea9ae3693505ce4876c32e0e7e25e60a5ab9f18ff05244749c446975e3
MD5 bc55f6bcd42012c24ff428159407c82c
BLAKE2b-256 8a448cd0559090bd3e1981da96266f591bc22e550bc212846b0118cbd0b5617b

See more details on using hashes here.

File details

Details for the file compactxml-2.1.0-py2.7.egg.

File metadata

File hashes

Hashes for compactxml-2.1.0-py2.7.egg
Algorithm Hash digest
SHA256 3027c8afcee8e7c17fb365e402cd45cfeaf23e9a739d990d5ecbb96d6e30e6ec
MD5 44a4b4f90af16c7083f1f4b357cf227f
BLAKE2b-256 9b37e74b22da3a861214991fbe78bcf3713945f89ef776cefea1a8cee88595d5

See more details on using hashes here.

Supported by

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