File: bindings.py.jinja

package info (click to toggle)
python-xmlschema 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,208 kB
  • sloc: python: 39,174; xml: 1,282; makefile: 36
file content (31 lines) | stat: -rw-r--r-- 997 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
# Copyright (c), 2016-2021, SISSA (International School for Advanced Studies).
# All rights reserved.
# This file 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.
#
# Auto-generated code: don't edit this file
#
"""
Sample of XML data bindings for schema {{ schema.name }}
"""
import xmlschema
from xmlschema.dataobjects import DataElement, DataBindingMeta

{% if schema.target_namespace -%}
__NAMESPACE__ = "{{ schema.target_namespace }}"
{%- endif %}

{% if schema.XSD_VERSION == '1.0' -%}
schema = xmlschema.XMLSchema10("{{ schema.name }}")
{%- else -%}
schema = xmlschema.XMLSchema11("{{ schema.name }}")
{%- endif -%}

{# Bindings for global elements #}
{% for xsd_element in schema.elements.values() %}

class {{ xsd_element|name|capitalize }}Binding(DataElement, metaclass=DataBindingMeta):
    xsd_element = schema.elements['{{ xsd_element.local_name }}']
{% endfor %}