https://github.com/unistra/lxml-element-maker
  
  
    Transforms a python structure to an xml element with lxml 
    https://github.com/unistra/lxml-element-maker
  
        Last synced: 8 months ago 
        JSON representation
    
Transforms a python structure to an xml element with lxml
- Host: GitHub
- URL: https://github.com/unistra/lxml-element-maker
- Owner: unistra
- Created: 2016-11-17T09:20:01.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-07-06T19:20:56.000Z (over 3 years ago)
- Last Synced: 2025-02-16T09:35:13.832Z (9 months ago)
- Language: Python
- Homepage:
- Size: 176 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 1
- 
            Metadata Files:
            - Readme: README.rst
 
Awesome Lists containing this project
README
          lxml-element-maker
==================
.. image:: https://api.travis-ci.org/unistra/lxml-element-maker.svg?branch=master
    :target: https://travis-ci.org/unistra/lxml-element-maker
    :alt: Build
.. image:: http://coveralls.io/repos/unistra/lxml-element-maker/badge.png?branch=master
    :target: http://coveralls.io/r/unistra/lxml-element-maker?branch=master
    :alt: Coverage
.. image:: https://img.shields.io/pypi/v/lxml-element-maker.svg
    :target: https://pypi.python.org/pypi/lxml-element-maker
    :alt: Version
.. image:: https://img.shields.io/pypi/pyversions/lxml-element-maker.svg
    :target: https://pypi.python.org/pypi/lxml-element-maker
    :alt: Python Version
.. image:: https://img.shields.io/pypi/status/lxml-element-maker.svg
    :target: https://pypi.python.org/pypi/lxml-element-maker
    :alt: Python Version
.. image:: https://img.shields.io/pypi/l/lxml-element-maker.svg
    :target: https://docs.python.org/3/license.html
    :alt: Licence
Requirements
------------
* python 3.4
* lxml 3.4.4
Install
-------
.. code:: bash
    pip install lxml-element-maker
Usage
-----
Transforms a python structure to an xml element with lxml :
.. code:: python
    from element_maker.utils import XMLElement
    structure = {'ArchiveTransferRequest':
                          [
                              [
                                  {'Comment': [
                                      ['baz'], {"foo": "bar"}
                                  ]
                                  },
                                  {'Date': [
                                      ["2014-05-12T00:00:00Z"]
                                  ]
                                  }
                              ],
                              {"cars": "pizza"}
                          ]
                          }
    namespace = "fr:gouv:culture:archivesdefrance:seda:v1.0"
    xml_element = XMLElement(namespace=self.namespace, **self.structure)()
    # Test the element with an xsd schema
    result = xml_element.pass_xsd("./tests/data/test.xsd")
    # Or test the element with an rng schema
    result2 = xml_element.pass_rng("./tests/data/test.rng")
The result is an xml :
.. code:: xml
    
        baz
        2014-05-12T00:00:00Z
    
Authors
-------
* Geoffroy : https://github.com/orgs/unistra/people/geoffroybeck
* Morgan : https://github.com/orgs/unistra/people/dotmobo