Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Converting Python objects to XML and back again.

Project Description

Marshals simple Python data types into a custom XML format. The Marshaller and Unmarshaller classes can be subclassed in order to implement marshalling into a different XML DTD. Original Authors are XML-SIG (xml-sig@python.org).

Fully compatible with PyXML implementation, enable namespace support for XML Input/Output.

Implemented with lxml

Installation

python setup.py install

Testing

python setup.py test

Usage

For simple serialisation and unserialisation:

>>> from xml_marshaller import xml_marshaller
>>> xml_marshaller.dumps(['item1', {'key1': 1, 'key2': u'unicode string'}])
'<marshal><list id="i2"><string>item1</string><dictionary id="i3"><string>key1</string><int>1</int><string>key2</string><unicode>unicode string</unicode></dictionary></list></marshal>'
>>> xml_marshaller.loads(xml_marshaller.dumps(['item1', {'key1': 1, 'key2': u'unicode string'}]))
['item1', {'key2': u'unicode string', 'key1': 1}]

Can works with file like objects:

>>> from xml_marshaller import xml_marshaller
>>> from StringIO import StringIO
>>> file_like_object = StringIO()
>>> xml_marshaller.dump('Hello World !', file_like_object)
>>> file_like_object.seek(0)
>>> file_like_object.read()
'<marshal><string>Hello World !</string></marshal>'
>>> file_like_object.seek(0)
>>> xml_marshaller.load(file_like_object)
'Hello World !'

xml_marshaller can also output xml with qualified names:

>>> from xml_marshaller import xml_marshaller
>>> xml_marshaller.dumps_ns('Hello World !')
'<marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller"><marshal:string>Hello World !</marshal:string></marshal:marshal>'

You can also use your own URI:

>>> from xml_marshaller.xml_marshaller import Marshaller
>>> marshaller = Marshaller(namespace_uri='http://my-custom-namespace-uri/namespace')
>>> marshaller.dumps('Hello World !')
'<marshal:marshal xmlns:marshal="http://my-custom-namespace-uri/namespace"><marshal:string>Hello World !</marshal:string></marshal:marshal>'

History

0.9.8dev (unreleased)

0.9.7 (2010-10-30)

  • Enhance egg folder structure
    [nicolas Delaby]
  • Improve tests
    [nicolas Delaby]
  • add XSD Schema
    [nicolas Delaby]

0.9.6 (2010-10-12)

  • [fix] Support boolean transformation
    [Nicolas Delaby]

0.9.5 (2010-09-01)

  • [fix] Formatting of documentation
    [Lukasz Nowak]

0.9.4 (2010-09-01)

  • [fix] Instances are now correctly unmarshalled.
    [Cedric de Saint Martin]
Release History

Release History

This version
History Node

0.9.7

History Node

0.9.6

History Node

0.9.5

History Node

0.9.4

History Node

0.9.3

History Node

0.9.2

History Node

0.9.1

History Node

0.9

History Node

0.9a

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
xml_marshaller-0.9.7.tar.gz (11.3 kB) Copy SHA256 Checksum SHA256 Source Oct 30, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting