| 1 |
# |
| 2 |
# Copyright (c), 2016-2021, SISSA (International School for Advanced Studies). |
| 3 |
# All rights reserved. |
| 4 |
# This file is distributed under the terms of the MIT License. |
| 5 |
# See the file 'LICENSE' in the root directory of the present |
| 6 |
# distribution, or http://opensource.org/licenses/MIT. |
| 7 |
# |
| 8 |
# Auto-generated code: don't edit this file |
| 9 |
# |
| 10 |
""" |
| 11 |
Sample of XML data bindings for schema {{ schema.name }} |
| 12 |
""" |
| 13 |
import xmlschema |
| 14 |
from xmlschema.dataobjects import DataElement, DataBindingMeta |
| 15 |
|
| 16 |
{% if schema.target_namespace -%} |
| 17 |
__NAMESPACE__ = "{{ schema.target_namespace }}" |
| 18 |
{%- endif %} |
| 19 |
|
| 20 |
{% if schema.XSD_VERSION == '1.0' -%} |
| 21 |
schema = xmlschema.XMLSchema10("{{ schema.name }}") |
| 22 |
{%- else -%} |
| 23 |
schema = xmlschema.XMLSchema11("{{ schema.name }}") |
| 24 |
{%- endif -%} |
| 25 |
|
| 26 |
{# Bindings for global elements #} |
| 27 |
{% for xsd_element in schema.elements.values() %} |
| 28 |
|
| 29 |
class {{ xsd_element|name|capitalize }}Binding(DataElement, metaclass=DataBindingMeta): |
| 30 |
xsd_element = schema.elements['{{ xsd_element.local_name }}'] |
| 31 |
{% endfor %} |