This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This is an implementation of XML Schema for Python (supports versions 2.7 and Python 3).

Features

  • Validate the XML instances to an XML schema
  • Provides data type conversion from and to XML
  • Converts XML instances to Python dictionaries

Installation and usage

You can install the library with:

pip install xmlschema

then you can import the library:

import xmlschema

and create an instance of a schema with:

my_schema = xmlschema.XMLSchema(<path to your XSD schema file>)

Validation

Using a XMLSchema instance you can validate files based on that schema:

my_schema.is_valid(<path to an XML file based on your XSD schema>)

that returns a boolean value, or:

my_schema.validate(<path to an XML file based on your XSD schema>)

to raise an error when the file is not validated.

If you need to validate once a file you can the module’s call:

xmlschema.validate(<path to the XML file>, <path to XSD schema file>)

Data conversion

A schema instance includes APIs for XSD types defined on the schema:

my_schema.types[<XSD type name>].decode(<XML text>)       # Decode XML text to data
my_schema.types[<XSD type name>].encode(<data instance>)  # Decode a data to and XML text

You can also converts the entire XML document to a nested dictionary with data conversion:

from xml.etree import ElementTree
my_xml = ElementTree.parse(<path to an XML file based on your XSD schema>)
my_schema = xmlschema.XMLSchema(<path to your XSD schema file>)
xmlschema.etree_to_dict(my_xml, my_schema)

Running Tests

The package uses the Python’s unitest library. The tests are located in tests/ directory. There are three scripts to test the package:

tests/test_schemas.py
Tests about parsing of XSD Schemas
tests/test_validation.py
Tests about XML validation
tests/test_decoding.py
Tests regarding XML data decoding

There are some basic tests published on xmlschema’s GitHub repository, but you can add your own tests in a subdirectory as a Git module:

mkdir tests/my_schemas
cd tests/my_schemas
git init
touch testfiles

Add to this file the relative or absolute paths of files to be tested, one per line. The file path maybe followed by the number of errors that have to be found in the XML to pass the test.

Release Notes

This release conforming to XML Schema version 1.0, but maybe extended to 1.1 in nearly future releases. Maybe soon will be available a manual for users and developers.

License

This software is distributed under the terms of the MIT License. See the file ‘LICENSE’ in the root directory of the present distribution, or http://opensource.org/licenses/MIT.

Release History

Release History

0.8b2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.8b1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.8a6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
xmlschema-0.8b2-py2.py3-none-any.whl (91.5 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Dec 7, 2016
xmlschema-0.8b2.tar.gz (62.8 kB) Copy SHA256 Checksum SHA256 Source Dec 7, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development 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