Debian Codegraph @

xmlschema/extras/templates/python/sample.py.jinja

raw
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 XSD generated code using test PythonGenerator class.
12 """
13 import xmlschema
14
15 {% if schema.target_namespace -%}
16 __NAMESPACE__ = "{{ schema.target_namespace }}"
17 {%- endif %}
18 #
19 # Schema types
20 #
21 {#- Render global types #}
22 {% for xsd_type in ( schema.types.values()|sort_types ) %}
23 class {{ xsd_type|name }}:
24
25 content_type = '{{ xsd_type.content_type_label }}'
26
27 {% endfor %}
28
29 #
30 # Schema elements
31 #
32 {#- Render global elements #}
33 {% for xsd_element in schema.elements.values() %}
34 class {{ xsd_element|name|capitalize }}:
35 {% if xsd_element.type.is_global() -%}
36
37 xsd_type = {{ xsd_element.type|name }}
38
39 {%- elif xsd_element.type.is_simple() -%}
40
41 xsd_type = {{ xsd_element.type.root_type|name }}
42
43 {%- else %}
44
45 pass
46
47 {%- endif %}
48
49 {% endfor %}