{"id":13469299,"url":"https://github.com/sissaschool/xmlschema","last_synced_at":"2025-10-21T13:07:50.151Z","repository":{"id":38028099,"uuid":"70905710","full_name":"sissaschool/xmlschema","owner":"sissaschool","description":"XML Schema validator and data conversion library for Python","archived":false,"fork":false,"pushed_at":"2025-03-22T07:35:44.000Z","size":4962,"stargazers_count":435,"open_issues_count":16,"forks_count":75,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-25T03:02:55.122Z","etag":null,"topics":["decoder","elementtree","encoder","lxml","validator","xml","xml-data-binding","xmlschema","xmlschema11","xsd"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sissaschool.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":"publiccode.yml","codemeta":null}},"created_at":"2016-10-14T11:52:54.000Z","updated_at":"2025-03-22T07:35:48.000Z","dependencies_parsed_at":"2024-04-17T18:46:31.685Z","dependency_job_id":"417b07dd-bb6c-4c40-ac4f-4dbcdf3b6690","html_url":"https://github.com/sissaschool/xmlschema","commit_stats":{"total_commits":1363,"total_committers":38,"mean_commits":35.86842105263158,"dds":0.06162876008804108,"last_synced_commit":"4ad7a4874ace3e1125c25a17b6fdbe2bb4c7f18c"},"previous_names":[],"tags_count":106,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sissaschool%2Fxmlschema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sissaschool%2Fxmlschema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sissaschool%2Fxmlschema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sissaschool%2Fxmlschema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sissaschool","download_url":"https://codeload.github.com/sissaschool/xmlschema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245604096,"owners_count":20642938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decoder","elementtree","encoder","lxml","validator","xml","xml-data-binding","xmlschema","xmlschema11","xsd"],"created_at":"2024-07-31T15:01:32.353Z","updated_at":"2025-10-21T13:07:50.144Z","avatar_url":"https://github.com/sissaschool.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"*********\nxmlschema\n*********\n\n.. image:: https://img.shields.io/pypi/v/xmlschema.svg\n   :target: https://pypi.python.org/pypi/xmlschema/\n.. image:: https://img.shields.io/pypi/pyversions/xmlschema.svg\n   :target: https://pypi.python.org/pypi/xmlschema/\n.. image:: https://img.shields.io/pypi/implementation/xmlschema.svg\n   :target: https://pypi.python.org/pypi/xmlschema/\n.. image:: https://img.shields.io/badge/License-MIT-blue.svg\n   :alt: MIT License\n   :target: https://lbesson.mit-license.org/\n.. image:: https://img.shields.io/pypi/dm/xmlschema.svg\n   :target: https://pypi.python.org/pypi/xmlschema/\n\n.. xmlschema-introduction-start\n\nThe *xmlschema* library is an implementation of `XML Schema \u003chttp://www.w3.org/2001/XMLSchema\u003e`_\nfor Python.\n\nThis library arises from the needs of a solid Python layer for processing XML\nSchema based files for\n`MaX (Materials design at the Exascale) \u003chttp://www.max-centre.eu\u003e`_  European project.\nA significant problem is the encoding and the decoding of the XML data files\nproduced by different simulation software.\nAnother important requirement is the XML data validation, in order to put the\nproduced data under control. The lack of a suitable alternative for Python in\nthe schema-based decoding of XML data has led to build this library. Obviously\nthis library can be useful for other cases related to XML Schema based processing,\nnot only for the original scope.\n\nThe full `xmlschema documentation is available on \"Read the Docs\" \u003chttp://xmlschema.readthedocs.io/en/latest/\u003e`_.\n\n\nFeatures\n========\n\nThis library includes the following features:\n\n* Full XSD 1.0 and XSD 1.1 support\n* Building of XML schema objects from XSD files\n* Validation of XML instances against XSD schemas\n* Decoding of XML data into Python data and to JSON\n* Encoding of Python data and JSON to XML\n* Data decoding and encoding ruled by converter classes\n* An XPath based API for finding schema's elements and attributes\n* Support of XSD validation modes *strict*/*lax*/*skip*\n* XML attacks protection using an XMLParser that forbids entities\n* Access control on resources addressed by an URL or filesystem path\n* Downloading XSD files from a remote URL and storing them for offline use\n* XML data bindings based on DataElement class\n* Static code generation with Jinja2 templates\n\n\nInstallation\n============\n\nYou can install the library with *pip* in a Python environment::\n\n    pip install xmlschema\n\nThe library uses the Python's ElementTree XML library and requires\n`elementpath \u003chttps://github.com/brunato/elementpath\u003e`_ additional package.\nThe base schemas of the XSD standards are included in the package for working\noffline and to speed-up the building of schema instances.\n\n.. xmlschema-introduction-end\n\n\nUsage\n=====\n\nImport the library and then create a schema instance using the path of\nthe file containing the schema as argument:\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e import xmlschema\n    \u003e\u003e\u003e my_schema = xmlschema.XMLSchema('tests/test_cases/examples/vehicles/vehicles.xsd')\n\n.. note::\n    For XSD 1.1 schemas use the class `XMLSchema11`, because the default class\n    `XMLSchema` is an alias of the XSD 1.0 validator class `XMLSchema10`.\n\nThe schema can be used to validate XML documents:\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e my_schema.is_valid('tests/test_cases/examples/vehicles/vehicles.xml')\n    True\n    \u003e\u003e\u003e my_schema.is_valid('tests/test_cases/examples/vehicles/vehicles-1_error.xml')\n    False\n    \u003e\u003e\u003e my_schema.validate('tests/test_cases/examples/vehicles/vehicles-1_error.xml')\n    Traceback (most recent call last):\n      File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n      File \"/home/brunato/Development/projects/xmlschema/xmlschema/validators/xsdbase.py\", line 393, in validate\n        raise error\n    xmlschema.validators.exceptions.XMLSchemaValidationError: failed validating \u003cElement '{http://example.com/vehicles}cars' at 0x7f8032768458\u003e with XsdGroup(model='sequence').\n\n    Reason: character data between child elements not allowed!\n\n    Schema:\n\n      \u003cxs:sequence xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\u003e\n            \u003cxs:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"car\" type=\"vh:vehicleType\" /\u003e\n      \u003c/xs:sequence\u003e\n\n    Instance:\n\n      \u003cvh:cars xmlns:vh=\"http://example.com/vehicles\"\u003e\n        NOT ALLOWED CHARACTER DATA\n        \u003cvh:car make=\"Porsche\" model=\"911\" /\u003e\n        \u003cvh:car make=\"Porsche\" model=\"911\" /\u003e\n      \u003c/vh:cars\u003e\n\nUsing a schema you can also decode the XML documents to nested dictionaries, with\nvalues that match to the data types declared by the schema:\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e import xmlschema\n    \u003e\u003e\u003e from pprint import pprint\n    \u003e\u003e\u003e xs = xmlschema.XMLSchema('tests/test_cases/examples/collection/collection.xsd')\n    \u003e\u003e\u003e pprint(xs.to_dict('tests/test_cases/examples/collection/collection.xml'))\n    {'@xsi:schemaLocation': 'http://example.com/ns/collection collection.xsd',\n     'object': [{'@available': True,\n                 '@id': 'b0836217462',\n                 'author': {'@id': 'PAR',\n                            'born': '1841-02-25',\n                            'dead': '1919-12-03',\n                            'name': 'Pierre-Auguste Renoir',\n                            'qualification': 'painter'},\n                 'estimation': Decimal('10000.00'),\n                 'position': 1,\n                 'title': 'The Umbrellas',\n                 'year': '1886'},\n                {'@available': True,\n                 '@id': 'b0836217463',\n                 'author': {'@id': 'JM',\n                            'born': '1893-04-20',\n                            'dead': '1983-12-25',\n                            'name': 'Joan Miró',\n                            'qualification': 'painter, sculptor and ceramicist'},\n                 'position': 2,\n                 'title': None,\n                 'year': '1925'}]}\n\n\nAuthors\n=======\nDavide Brunato and others who have contributed with code or with sample cases.\n\nLicense\n=======\nThis software is distributed under the terms of the MIT License.\nSee the file 'LICENSE' in the root directory of the present\ndistribution, or http://opensource.org/licenses/MIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsissaschool%2Fxmlschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsissaschool%2Fxmlschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsissaschool%2Fxmlschema/lists"}