author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Wed, 12 Apr 2023 21:05:00 +0200 | |
branch | python3 |
changeset 3793 | 9958cf865da0 |
parent 3752 | 9f6f46dbe3ae |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
814 | 6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
814 | 8 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
814 | 10 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
814 | 15 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
19 |
# GNU General Public License for more details. |
814 | 20 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1375
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 24 |
|
1826
91796f408540
fix usage of python2-only print statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
25 |
|
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
26 |
import os |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
27 |
import re |
814 | 28 |
import datetime |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
29 |
from types import FunctionType |
814 | 30 |
from xml.dom import minidom |
31 |
||
1853
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1852
diff
changeset
|
32 |
from xmlclass.xmlclass import * |
814 | 33 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
34 |
|
814 | 35 |
def GenerateDictFacets(facets): |
36 |
return dict([(name, (None, False)) for name in facets]) |
|
37 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
38 |
|
814 | 39 |
def GenerateSimpleTypeXMLText(function): |
40 |
def generateXMLTextMethod(value, name=None, indent=0): |
|
41 |
text = "" |
|
42 |
if name is not None: |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
43 |
ind1, _ind2 = getIndent(indent, name) |
814 | 44 |
text += ind1 + "<%s>" % name |
45 |
text += function(value) |
|
46 |
if name is not None: |
|
47 |
text += "</%s>\n" % name |
|
48 |
return text |
|
49 |
return generateXMLTextMethod |
|
50 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
51 |
|
1852
70c1cc354a8f
fix pylint warning '(dangerous-default-value) Dangerous default value {} as argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1849
diff
changeset
|
52 |
def GenerateFloatXMLText(extra_values=None, decimal=None): |
1374
1eefc427419f
Fixed bug with decimal value string formatting
Laurent Bessard
parents:
1373
diff
changeset
|
53 |
float_format = (lambda x: "{:.{width}f}".format(x, width=decimal).rstrip('0') |
1eefc427419f
Fixed bug with decimal value string formatting
Laurent Bessard
parents:
1373
diff
changeset
|
54 |
if decimal is not None else str) |
1852
70c1cc354a8f
fix pylint warning '(dangerous-default-value) Dangerous default value {} as argument'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1849
diff
changeset
|
55 |
extra_values = [] if extra_values is None else extra_values |
1750
acf02488f37f
clean-up: fix PEP8 E306 expected 1 blank line before a nested definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
56 |
|
814 | 57 |
def generateXMLTextMethod(value, name=None, indent=0): |
58 |
text = "" |
|
59 |
if name is not None: |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
60 |
ind1, _ind2 = getIndent(indent, name) |
814 | 61 |
text += ind1 + "<%s>" % name |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
62 |
if isinstance(value, int): |
1375
dc94c71a2f25
Fixed bug with decimal value string formatting
Laurent Bessard
parents:
1374
diff
changeset
|
63 |
text += str(value) |
dc94c71a2f25
Fixed bug with decimal value string formatting
Laurent Bessard
parents:
1374
diff
changeset
|
64 |
elif value in extra_values or value % 1 != 0: |
1373
4278d5c1e414
Fixed bug when graphic element position and size and connection points are decimal
Laurent Bessard
parents:
1322
diff
changeset
|
65 |
text += float_format(value) |
814 | 66 |
else: |
1375
dc94c71a2f25
Fixed bug with decimal value string formatting
Laurent Bessard
parents:
1374
diff
changeset
|
67 |
text += "{:.0f}".format(value) |
814 | 68 |
if name is not None: |
69 |
text += "</%s>\n" % name |
|
70 |
return text |
|
71 |
return generateXMLTextMethod |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
72 |
|
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
73 |
|
814 | 74 |
DEFAULT_FACETS = GenerateDictFacets(["pattern", "whiteSpace", "enumeration"]) |
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
75 |
NUMBER_FACETS = GenerateDictFacets(list(DEFAULT_FACETS.keys()) + ["maxInclusive", "maxExclusive", "minInclusive", "minExclusive"]) |
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
76 |
DECIMAL_FACETS = GenerateDictFacets(list(NUMBER_FACETS.keys()) + ["totalDigits", "fractionDigits"]) |
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
77 |
STRING_FACETS = GenerateDictFacets(list(DEFAULT_FACETS.keys()) + ["length", "minLength", "maxLength"]) |
814 | 78 |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
79 |
ALL_FACETS = ["pattern", "whiteSpace", "enumeration", "maxInclusive", |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
80 |
"maxExclusive", "minInclusive", "minExclusive", "totalDigits", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
81 |
"fractionDigits", "length", "minLength", "maxLength"] |
814 | 82 |
|
83 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
84 |
# ------------------------------------------------------------------------------- |
814 | 85 |
# Structure reducing functions |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
86 |
# ------------------------------------------------------------------------------- |
814 | 87 |
|
88 |
||
89 |
# Documentation elements |
|
90 |
||
91 |
def ReduceAppInfo(factory, attributes, elements): |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
92 |
return {"type": "appinfo", "source": attributes.get("source", None), |
814 | 93 |
"content": "\n".join(elements)} |
94 |
||
95 |
||
96 |
def ReduceDocumentation(factory, attributes, elements): |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
97 |
return {"type": "documentation", "source": attributes.get("source", None), |
814 | 98 |
"language": attributes.get("lang", "any"), "content": "\n".join(elements)} |
99 |
||
100 |
||
101 |
def ReduceAnnotation(factory, attributes, elements): |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
102 |
_annotations, children = factory.ReduceElements(elements) |
814 | 103 |
annotation = {"type": "annotation", "appinfo": [], "documentation": {}} |
104 |
for child in children: |
|
105 |
if child["type"] == "appinfo": |
|
106 |
annotation["appinfo"].append((child["source"], child["content"])) |
|
107 |
elif child["type"] == "documentation": |
|
108 |
if child["source"] is not None: |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
109 |
text = "(source: %(source)s):\n%(content)s\n\n" % child |
814 | 110 |
else: |
111 |
text = child["content"] + "\n\n" |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
112 |
if not child["language"] in annotation["documentation"]: |
814 | 113 |
annotation["documentation"] = text |
114 |
else: |
|
115 |
annotation["documentation"] += text |
|
116 |
return annotation |
|
117 |
||
118 |
# Simple type elements |
|
119 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
120 |
|
814 | 121 |
def GenerateFacetReducing(facetname, canbefixed): |
122 |
def ReduceFacet(factory, attributes, elements): |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
123 |
annotations, _children = factory.ReduceElements(elements) |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
124 |
if "value" in attributes: |
814 | 125 |
facet = {"type": facetname, "value": attributes["value"], "doc": annotations} |
126 |
if canbefixed: |
|
127 |
facet["fixed"] = attributes.get("fixed", False) |
|
128 |
return facet |
|
129 |
raise ValueError("A value must be defined for the \"%s\" facet!" % facetname) |
|
130 |
return ReduceFacet |
|
131 |
||
132 |
||
133 |
def ReduceList(factory, attributes, elements): |
|
134 |
annotations, children = factory.ReduceElements(elements) |
|
135 |
list = {"type": "list", "itemType": attributes.get("itemType", None), "doc": annotations} |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
136 |
|
814 | 137 |
if len(children) > 0 and children[0]["type"] == SIMPLETYPE: |
138 |
if list["itemType"] is None: |
|
139 |
list["itemType"] = children[0] |
|
140 |
else: |
|
141 |
raise ValueError("Only one base type can be defined for restriction!") |
|
142 |
if list["itemType"] is None: |
|
143 |
raise ValueError("No base type has been defined for list!") |
|
144 |
return list |
|
145 |
||
146 |
||
147 |
def ReduceUnion(factory, attributes, elements): |
|
148 |
annotations, children = factory.ReduceElements(elements) |
|
149 |
union = {"type": "union", "memberTypes": attributes.get("memberTypes", []), "doc": annotations} |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
150 |
|
814 | 151 |
for child in children: |
152 |
if child["type"] == SIMPLETYPE: |
|
1856
c2cba67145eb
fix error found by pylint 'W0104(pointless-statement) Statement seems to have no effect'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
153 |
union["memberTypes"].append(child) |
814 | 154 |
if len(union["memberTypes"]) == 0: |
155 |
raise ValueError("No base type has been defined for union!") |
|
156 |
return union |
|
157 |
||
158 |
||
159 |
def CreateSimpleType(factory, attributes, typeinfos): |
|
160 |
# Initialize type informations |
|
161 |
facets = {} |
|
162 |
simpleType = {"type": SIMPLETYPE, "final": attributes.get("final", [])} |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
163 |
if "name" in attributes: |
814 | 164 |
simpleType["name"] = attributes["name"] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
165 |
|
814 | 166 |
if typeinfos["type"] in ["restriction", "extension"]: |
167 |
# Search for base type definition |
|
3752 | 168 |
if isinstance(typeinfos["base"], str): |
814 | 169 |
basetypeinfos = factory.FindSchemaElement(typeinfos["base"], SIMPLETYPE) |
170 |
if basetypeinfos is None: |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
171 |
raise "\"%s\" isn't defined!" % typeinfos["base"] |
814 | 172 |
else: |
173 |
basetypeinfos = typeinfos["base"] |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
174 |
|
814 | 175 |
# Check that base type is a simple type |
176 |
if basetypeinfos["type"] != SIMPLETYPE: |
|
177 |
raise ValueError("Base type given isn't a simpleType!") |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
178 |
|
814 | 179 |
simpleType["basename"] = basetypeinfos["basename"] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
180 |
|
814 | 181 |
# Check that derivation is allowed |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
182 |
if "final" in basetypeinfos: |
814 | 183 |
if "#all" in basetypeinfos["final"]: |
184 |
raise ValueError("Base type can't be derivated!") |
|
185 |
if "restriction" in basetypeinfos["final"] and typeinfos["type"] == "restriction": |
|
186 |
raise ValueError("Base type can't be derivated by restriction!") |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
187 |
|
814 | 188 |
# Extract simple type facets |
189 |
for facet in typeinfos.get("facets", []): |
|
190 |
facettype = facet["type"] |
|
1775
b45f2768fab1
clean-up: fix PEP8 E713 test for membership should be 'not in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1774
diff
changeset
|
191 |
if facettype not in basetypeinfos["facets"]: |
814 | 192 |
raise ValueError("\"%s\" facet can't be defined for \"%s\" type!" % (facettype, type)) |
193 |
elif basetypeinfos["facets"][facettype][1]: |
|
194 |
raise ValueError("\"%s\" facet is fixed on base type!" % facettype) |
|
195 |
value = facet["value"] |
|
196 |
basevalue = basetypeinfos["facets"][facettype][0] |
|
197 |
if facettype in ["enumeration", "pattern"]: |
|
198 |
value = basetypeinfos["extract"](value, False) |
|
199 |
if len(facets) == 0: |
|
200 |
facets[facettype] = ([value], False) |
|
201 |
continue |
|
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
202 |
elif list(facets.keys()) == [facettype]: |
814 | 203 |
facets[facettype][0].append(value) |
204 |
continue |
|
205 |
else: |
|
206 |
raise ValueError("\"%s\" facet can't be defined with another facet type!" % facettype) |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
207 |
elif "enumeration" in facets: |
814 | 208 |
raise ValueError("\"enumeration\" facet can't be defined with another facet type!") |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
209 |
elif "pattern" in facets: |
814 | 210 |
raise ValueError("\"pattern\" facet can't be defined with another facet type!") |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
211 |
elif facettype in facets: |
814 | 212 |
raise ValueError("\"%s\" facet can't be defined two times!" % facettype) |
213 |
elif facettype == "length": |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
214 |
if "minLength" in facets: |
814 | 215 |
raise ValueError("\"length\" and \"minLength\" facets can't be defined at the same time!") |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
216 |
if "maxLength" in facets: |
814 | 217 |
raise ValueError("\"length\" and \"maxLength\" facets can't be defined at the same time!") |
218 |
try: |
|
219 |
value = int(value) |
|
1780
c52d1460cea8
clean-up: fix PEP8 E722 do not use bare except'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1776
diff
changeset
|
220 |
except Exception: |
814 | 221 |
raise ValueError("\"length\" must be an integer!") |
222 |
if value < 0: |
|
223 |
raise ValueError("\"length\" can't be negative!") |
|
224 |
elif basevalue is not None and basevalue != value: |
|
225 |
raise ValueError("\"length\" can't be different from \"length\" defined in base type!") |
|
226 |
elif facettype == "minLength": |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
227 |
if "length" in facets: |
814 | 228 |
raise ValueError("\"length\" and \"minLength\" facets can't be defined at the same time!") |
229 |
try: |
|
230 |
value = int(value) |
|
1780
c52d1460cea8
clean-up: fix PEP8 E722 do not use bare except'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1776
diff
changeset
|
231 |
except Exception: |
814 | 232 |
raise ValueError("\"minLength\" must be an integer!") |
233 |
if value < 0: |
|
234 |
raise ValueError("\"minLength\" can't be negative!") |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
235 |
elif "maxLength" in facets and value > facets["maxLength"]: |
814 | 236 |
raise ValueError("\"minLength\" must be lesser than or equal to \"maxLength\"!") |
237 |
elif basevalue is not None and basevalue < value: |
|
238 |
raise ValueError("\"minLength\" can't be lesser than \"minLength\" defined in base type!") |
|
239 |
elif facettype == "maxLength": |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
240 |
if "length" in facets: |
814 | 241 |
raise ValueError("\"length\" and \"maxLength\" facets can't be defined at the same time!") |
242 |
try: |
|
243 |
value = int(value) |
|
1780
c52d1460cea8
clean-up: fix PEP8 E722 do not use bare except'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1776
diff
changeset
|
244 |
except Exception: |
814 | 245 |
raise ValueError("\"maxLength\" must be an integer!") |
246 |
if value < 0: |
|
247 |
raise ValueError("\"maxLength\" can't be negative!") |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
248 |
elif "minLength" in facets and value < facets["minLength"]: |
814 | 249 |
raise ValueError("\"minLength\" must be lesser than or equal to \"maxLength\"!") |
250 |
elif basevalue is not None and basevalue > value: |
|
251 |
raise ValueError("\"maxLength\" can't be greater than \"maxLength\" defined in base type!") |
|
252 |
elif facettype == "minInclusive": |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
253 |
if "minExclusive" in facets: |
814 | 254 |
raise ValueError("\"minExclusive\" and \"minInclusive\" facets can't be defined at the same time!") |
255 |
value = basetypeinfos["extract"](facet["value"], False) |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
256 |
if "maxInclusive" in facets and value > facets["maxInclusive"][0]: |
814 | 257 |
raise ValueError("\"minInclusive\" must be lesser than or equal to \"maxInclusive\"!") |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
258 |
elif "maxExclusive" in facets and value >= facets["maxExclusive"][0]: |
814 | 259 |
raise ValueError("\"minInclusive\" must be lesser than \"maxExclusive\"!") |
260 |
elif facettype == "minExclusive": |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
261 |
if "minInclusive" in facets: |
814 | 262 |
raise ValueError("\"minExclusive\" and \"minInclusive\" facets can't be defined at the same time!") |
263 |
value = basetypeinfos["extract"](facet["value"], False) |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
264 |
if "maxInclusive" in facets and value >= facets["maxInclusive"][0]: |
814 | 265 |
raise ValueError("\"minExclusive\" must be lesser than \"maxInclusive\"!") |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
266 |
elif "maxExclusive" in facets and value >= facets["maxExclusive"][0]: |
814 | 267 |
raise ValueError("\"minExclusive\" must be lesser than \"maxExclusive\"!") |
268 |
elif facettype == "maxInclusive": |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
269 |
if "maxExclusive" in facets: |
814 | 270 |
raise ValueError("\"maxExclusive\" and \"maxInclusive\" facets can't be defined at the same time!") |
271 |
value = basetypeinfos["extract"](facet["value"], False) |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
272 |
if "minInclusive" in facets and value < facets["minInclusive"][0]: |
814 | 273 |
raise ValueError("\"minInclusive\" must be lesser than or equal to \"maxInclusive\"!") |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
274 |
elif "minExclusive" in facets and value <= facets["minExclusive"][0]: |
814 | 275 |
raise ValueError("\"minExclusive\" must be lesser than \"maxInclusive\"!") |
276 |
elif facettype == "maxExclusive": |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
277 |
if "maxInclusive" in facets: |
814 | 278 |
raise ValueError("\"maxExclusive\" and \"maxInclusive\" facets can't be defined at the same time!") |
279 |
value = basetypeinfos["extract"](facet["value"], False) |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
280 |
if "minInclusive" in facets and value <= facets["minInclusive"][0]: |
814 | 281 |
raise ValueError("\"minInclusive\" must be lesser than \"maxExclusive\"!") |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
282 |
elif "minExclusive" in facets and value <= facets["minExclusive"][0]: |
814 | 283 |
raise ValueError("\"minExclusive\" must be lesser than \"maxExclusive\"!") |
284 |
elif facettype == "whiteSpace": |
|
285 |
if basevalue == "collapse" and value in ["preserve", "replace"] or basevalue == "replace" and value == "preserve": |
|
1757
0de89da92ee0
clean-up: fix PEP8 E111 indentation is not a multiple of four
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1750
diff
changeset
|
286 |
raise ValueError("\"whiteSpace\" is incompatible with \"whiteSpace\" defined in base type!") |
814 | 287 |
elif facettype == "totalDigits": |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
288 |
if "fractionDigits" in facets and value <= facets["fractionDigits"][0]: |
814 | 289 |
raise ValueError("\"fractionDigits\" must be lesser than or equal to \"totalDigits\"!") |
290 |
elif basevalue is not None and value > basevalue: |
|
291 |
raise ValueError("\"totalDigits\" can't be greater than \"totalDigits\" defined in base type!") |
|
292 |
elif facettype == "fractionDigits": |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
293 |
if "totalDigits" in facets and value <= facets["totalDigits"][0]: |
814 | 294 |
raise ValueError("\"fractionDigits\" must be lesser than or equal to \"totalDigits\"!") |
295 |
elif basevalue is not None and value > basevalue: |
|
296 |
raise ValueError("\"totalDigits\" can't be greater than \"totalDigits\" defined in base type!") |
|
297 |
facets[facettype] = (value, facet.get("fixed", False)) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
298 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
299 |
# Report not redefined facet from base type to new created type |
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
300 |
for facettype, facetvalue in list(basetypeinfos["facets"].items()): |
1775
b45f2768fab1
clean-up: fix PEP8 E713 test for membership should be 'not in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1774
diff
changeset
|
301 |
if facettype not in facets: |
814 | 302 |
facets[facettype] = facetvalue |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
303 |
|
814 | 304 |
# Generate extract value for new created type |
305 |
def ExtractSimpleTypeValue(attr, extract=True): |
|
306 |
value = basetypeinfos["extract"](attr, extract) |
|
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
307 |
for facetname, (facetvalue, _facetfixed) in list(facets.items()): |
814 | 308 |
if facetvalue is not None: |
309 |
if facetname == "enumeration" and value not in facetvalue: |
|
310 |
raise ValueError("\"%s\" not in enumerated values" % value) |
|
311 |
elif facetname == "length" and len(value) != facetvalue: |
|
312 |
raise ValueError("value must have a length of %d" % facetvalue) |
|
313 |
elif facetname == "minLength" and len(value) < facetvalue: |
|
314 |
raise ValueError("value must have a length of %d at least" % facetvalue) |
|
315 |
elif facetname == "maxLength" and len(value) > facetvalue: |
|
316 |
raise ValueError("value must have a length of %d at most" % facetvalue) |
|
317 |
elif facetname == "minInclusive" and value < facetvalue: |
|
318 |
raise ValueError("value must be greater than or equal to %s" % str(facetvalue)) |
|
319 |
elif facetname == "minExclusive" and value <= facetvalue: |
|
320 |
raise ValueError("value must be greater than %s" % str(facetvalue)) |
|
321 |
elif facetname == "maxInclusive" and value > facetvalue: |
|
322 |
raise ValueError("value must be lesser than or equal to %s" % str(facetvalue)) |
|
1774
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
323 |
elif facetname == "maxExclusive" and value >= facetvalue: |
814 | 324 |
raise ValueError("value must be lesser than %s" % str(facetvalue)) |
325 |
elif facetname == "pattern": |
|
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
326 |
model = re.compile("(?:%s)?$" % "|".join(["(?:%s)" % x for x in facetvalue])) |
814 | 327 |
result = model.match(value) |
328 |
if result is None: |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
329 |
if len(facetvalue) > 1: |
814 | 330 |
raise ValueError("value doesn't follow any of the patterns %s" % ",".join(facetvalue)) |
331 |
else: |
|
332 |
raise ValueError("value doesn't follow the pattern %s" % facetvalue[0]) |
|
333 |
elif facetname == "whiteSpace": |
|
334 |
if facetvalue == "replace": |
|
335 |
value = GetNormalizedString(value, False) |
|
336 |
elif facetvalue == "collapse": |
|
337 |
value = GetToken(value, False) |
|
338 |
return value |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
339 |
|
814 | 340 |
def CheckSimpleTypeValue(value): |
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
341 |
for facetname, (facetvalue, _facetfixed) in list(facets.items()): |
814 | 342 |
if facetvalue is not None: |
343 |
if facetname == "enumeration" and value not in facetvalue: |
|
344 |
return False |
|
345 |
elif facetname == "length" and len(value) != facetvalue: |
|
346 |
return False |
|
347 |
elif facetname == "minLength" and len(value) < facetvalue: |
|
348 |
return False |
|
349 |
elif facetname == "maxLength" and len(value) > facetvalue: |
|
350 |
return False |
|
351 |
elif facetname == "minInclusive" and value < facetvalue: |
|
352 |
return False |
|
353 |
elif facetname == "minExclusive" and value <= facetvalue: |
|
354 |
return False |
|
355 |
elif facetname == "maxInclusive" and value > facetvalue: |
|
356 |
return False |
|
1774
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
357 |
elif facetname == "maxExclusive" and value >= facetvalue: |
814 | 358 |
return False |
359 |
elif facetname == "pattern": |
|
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
360 |
model = re.compile("(?:%s)?$" % "|".join(["(?:%s)" % x for x in facetvalue])) |
814 | 361 |
result = model.match(value) |
362 |
if result is None: |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
363 |
if len(facetvalue) > 1: |
814 | 364 |
raise ValueError("value doesn't follow any of the patterns %s" % ",".join(facetvalue)) |
365 |
else: |
|
366 |
raise ValueError("value doesn't follow the pattern %s" % facetvalue[0]) |
|
367 |
return True |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
368 |
|
814 | 369 |
def SimpleTypeInitialValue(): |
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
370 |
for facetname, (facetvalue, _facetfixed) in list(facets.items()): |
814 | 371 |
if facetvalue is not None: |
372 |
if facetname == "enumeration": |
|
373 |
return facetvalue[0] |
|
374 |
elif facetname == "length": |
|
375 |
return " "*facetvalue |
|
376 |
elif facetname == "minLength": |
|
1872
866fb3ab8778
fix pylint error "(undefined-variable) Undefined variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1856
diff
changeset
|
377 |
return " "*facetvalue |
814 | 378 |
elif facetname == "minInclusive" and facetvalue > 0: |
379 |
return facetvalue |
|
380 |
elif facetname == "minExclusive" and facetvalue >= 0: |
|
381 |
return facetvalue + 1 |
|
382 |
elif facetname == "maxInclusive" and facetvalue < 0: |
|
383 |
return facetvalue |
|
1774
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
384 |
elif facetname == "maxExclusive" and facetvalue <= 0: |
814 | 385 |
return facetvalue - 1 |
386 |
return basetypeinfos["initial"]() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
387 |
|
814 | 388 |
GenerateSimpleType = basetypeinfos["generate"] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
389 |
|
814 | 390 |
elif typeinfos["type"] == "list": |
391 |
# Search for item type definition |
|
3752 | 392 |
if isinstance(typeinfos["itemType"], str): |
814 | 393 |
itemtypeinfos = factory.FindSchemaElement(typeinfos["itemType"], SIMPLETYPE) |
394 |
if itemtypeinfos is None: |
|
395 |
raise "\"%s\" isn't defined!" % typeinfos["itemType"] |
|
396 |
else: |
|
397 |
itemtypeinfos = typeinfos["itemType"] |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
398 |
|
814 | 399 |
# Check that item type is a simple type |
400 |
if itemtypeinfos["type"] != SIMPLETYPE: |
|
1765
ccf59c1f0b45
clean-up: fix PEP8 W602 deprecated form of raising exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1763
diff
changeset
|
401 |
raise ValueError("Item type given isn't a simpleType!") |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
402 |
|
814 | 403 |
simpleType["basename"] = "list" |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
404 |
|
814 | 405 |
# Check that derivation is allowed |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
406 |
if "final" in itemtypeinfos: |
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
407 |
if "#all" in itemtypeinfos["final"]: |
814 | 408 |
raise ValueError("Item type can't be derivated!") |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
409 |
if "list" in itemtypeinfos["final"]: |
814 | 410 |
raise ValueError("Item type can't be derivated by list!") |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
411 |
|
814 | 412 |
# Generate extract value for new created type |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
413 |
def ExtractSimpleTypeValue(attr, extract=True): |
814 | 414 |
values = [] |
415 |
for value in GetToken(attr, extract).split(" "): |
|
416 |
values.append(itemtypeinfos["extract"](value, False)) |
|
417 |
return values |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
418 |
|
814 | 419 |
def CheckSimpleTypeValue(value): |
420 |
for item in value: |
|
421 |
result = itemtypeinfos["check"](item) |
|
422 |
if not result: |
|
423 |
return result |
|
424 |
return True |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
425 |
|
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1757
diff
changeset
|
426 |
def SimpleTypeInitialValue(): |
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1757
diff
changeset
|
427 |
return [] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
428 |
|
814 | 429 |
GenerateSimpleType = GenerateSimpleTypeXMLText(lambda x: " ".join(map(itemtypeinfos["generate"], x))) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
430 |
|
814 | 431 |
facets = GenerateDictFacets(["length", "maxLength", "minLength", "enumeration", "pattern"]) |
432 |
facets["whiteSpace"] = ("collapse", False) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
433 |
|
814 | 434 |
elif typeinfos["type"] == "union": |
435 |
# Search for member types definition |
|
436 |
membertypesinfos = [] |
|
437 |
for membertype in typeinfos["memberTypes"]: |
|
3752 | 438 |
if isinstance(membertype, str): |
814 | 439 |
infos = factory.FindSchemaElement(membertype, SIMPLETYPE) |
440 |
if infos is None: |
|
441 |
raise ValueError("\"%s\" isn't defined!" % membertype) |
|
442 |
else: |
|
443 |
infos = membertype |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
444 |
|
814 | 445 |
# Check that member type is a simple type |
446 |
if infos["type"] != SIMPLETYPE: |
|
447 |
raise ValueError("Member type given isn't a simpleType!") |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
448 |
|
814 | 449 |
# Check that derivation is allowed |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
450 |
if "final" in infos: |
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
451 |
if "#all" in infos["final"]: |
814 | 452 |
raise ValueError("Item type can't be derivated!") |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
453 |
if "union" in infos["final"]: |
814 | 454 |
raise ValueError("Member type can't be derivated by union!") |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
455 |
|
814 | 456 |
membertypesinfos.append(infos) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
457 |
|
814 | 458 |
simpleType["basename"] = "union" |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
459 |
|
814 | 460 |
# Generate extract value for new created type |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
461 |
def ExtractSimpleTypeValue(attr, extract=True): |
814 | 462 |
for infos in membertypesinfos: |
463 |
try: |
|
464 |
return infos["extract"](attr, False) |
|
1780
c52d1460cea8
clean-up: fix PEP8 E722 do not use bare except'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1776
diff
changeset
|
465 |
except Exception: |
814 | 466 |
pass |
467 |
raise ValueError("\"%s\" isn't valid for type defined for union!") |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
468 |
|
814 | 469 |
def CheckSimpleTypeValue(value): |
470 |
for infos in membertypesinfos: |
|
471 |
result = infos["check"](value) |
|
472 |
if result: |
|
473 |
return result |
|
474 |
return False |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
475 |
|
814 | 476 |
SimpleTypeInitialValue = membertypesinfos[0]["initial"] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
477 |
|
814 | 478 |
def GenerateSimpleTypeFunction(value): |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
479 |
if isinstance(value, bool): |
814 | 480 |
return {True: "true", False: "false"}[value] |
481 |
else: |
|
482 |
return str(value) |
|
483 |
GenerateSimpleType = GenerateSimpleTypeXMLText(GenerateSimpleTypeFunction) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
484 |
|
814 | 485 |
facets = GenerateDictFacets(["pattern", "enumeration"]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
486 |
|
814 | 487 |
simpleType["facets"] = facets |
488 |
simpleType["extract"] = ExtractSimpleTypeValue |
|
489 |
simpleType["initial"] = SimpleTypeInitialValue |
|
490 |
simpleType["check"] = CheckSimpleTypeValue |
|
491 |
simpleType["generate"] = GenerateSimpleType |
|
492 |
return simpleType |
|
493 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
494 |
|
814 | 495 |
def ReduceSimpleType(factory, attributes, elements): |
496 |
# Reduce all the simple type children |
|
497 |
annotations, children = factory.ReduceElements(elements) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
498 |
|
814 | 499 |
simpleType = CreateSimpleType(factory, attributes, children[0]) |
500 |
simpleType["doc"] = annotations |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
501 |
|
814 | 502 |
return simpleType |
503 |
||
504 |
# Complex type |
|
505 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
506 |
|
814 | 507 |
def ExtractAttributes(factory, elements, base=None): |
508 |
attrs = [] |
|
509 |
attrnames = {} |
|
510 |
if base is not None: |
|
511 |
basetypeinfos = factory.FindSchemaElement(base) |
|
3752 | 512 |
if not isinstance(basetypeinfos, str) and basetypeinfos["type"] == COMPLEXTYPE: |
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
513 |
attrnames = dict([(x["name"], True) for x in basetypeinfos["attributes"]]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
514 |
|
814 | 515 |
for element in elements: |
516 |
if element["type"] == ATTRIBUTE: |
|
517 |
if attrnames.get(element["name"], False): |
|
518 |
raise ValueError("\"%s\" attribute has been defined two times!" % element["name"]) |
|
519 |
else: |
|
520 |
attrnames[element["name"]] = True |
|
521 |
attrs.append(element) |
|
522 |
elif element["type"] == "attributeGroup": |
|
523 |
attrgroup = factory.FindSchemaElement(element["ref"], ATTRIBUTESGROUP) |
|
524 |
for attr in attrgroup["attributes"]: |
|
525 |
if attrnames.get(attr["name"], False): |
|
526 |
raise ValueError("\"%s\" attribute has been defined two times!" % attr["name"]) |
|
527 |
else: |
|
528 |
attrnames[attr["name"]] = True |
|
529 |
attrs.append(attr) |
|
530 |
elif element["type"] == "anyAttribute": |
|
531 |
raise ValueError("\"anyAttribute\" element isn't supported yet!") |
|
532 |
return attrs |
|
533 |
||
534 |
||
535 |
def ReduceRestriction(factory, attributes, elements): |
|
536 |
annotations, children = factory.ReduceElements(elements) |
|
537 |
restriction = {"type": "restriction", "base": attributes.get("base", None), "facets": [], "doc": annotations} |
|
538 |
if len(children) > 0 and children[0]["type"] == SIMPLETYPE: |
|
539 |
if restriction["base"] is None: |
|
540 |
restriction["base"] = children.pop(0) |
|
541 |
else: |
|
542 |
raise ValueError("Only one base type can be defined for restriction!") |
|
543 |
if restriction["base"] is None: |
|
544 |
raise ValueError("No base type has been defined for restriction!") |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
545 |
|
814 | 546 |
while len(children) > 0 and children[0]["type"] in ALL_FACETS: |
547 |
restriction["facets"].append(children.pop(0)) |
|
548 |
restriction["attributes"] = ExtractAttributes(factory, children, restriction["base"]) |
|
549 |
return restriction |
|
550 |
||
551 |
||
552 |
def ReduceExtension(factory, attributes, elements): |
|
553 |
annotations, children = factory.ReduceElements(elements) |
|
1775
b45f2768fab1
clean-up: fix PEP8 E713 test for membership should be 'not in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1774
diff
changeset
|
554 |
if "base" not in attributes: |
814 | 555 |
raise ValueError("No base type has been defined for extension!") |
556 |
extension = {"type": "extension", "attributes": [], "elements": [], "base": attributes["base"], "doc": annotations} |
|
557 |
if len(children) > 0: |
|
558 |
if children[0]["type"] in ["group", "all", CHOICE, "sequence"]: |
|
559 |
group = children.pop(0) |
|
560 |
if group["type"] in ["all", "sequence"]: |
|
561 |
extension["elements"] = group["elements"] |
|
562 |
extension["order"] = group["order"] |
|
563 |
elif group["type"] == CHOICE: |
|
564 |
content = group.copy() |
|
565 |
content["name"] = "content" |
|
566 |
extension["elements"].append(content) |
|
567 |
elif group["type"] == "group": |
|
1872
866fb3ab8778
fix pylint error "(undefined-variable) Undefined variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1856
diff
changeset
|
568 |
elmtgroup = factory.FindSchemaElement(group["ref"], ELEMENTSGROUP) |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
569 |
if "elements" in elmtgroup: |
814 | 570 |
extension["elements"] = elmtgroup["elements"] |
571 |
extension["order"] = elmtgroup["order"] |
|
572 |
else: |
|
573 |
content = elmtgroup.copy() |
|
574 |
content["name"] = "content" |
|
575 |
extension["elements"].append(content) |
|
576 |
extension["attributes"] = ExtractAttributes(factory, children) |
|
577 |
return extension |
|
578 |
||
579 |
||
580 |
def ReduceSimpleContent(factory, attributes, elements): |
|
581 |
annotations, children = factory.ReduceElements(elements) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
582 |
|
814 | 583 |
simpleContent = children[0].copy() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
584 |
|
814 | 585 |
basetypeinfos = factory.FindSchemaElement(simpleContent["base"]) |
586 |
if basetypeinfos["type"] == SIMPLETYPE: |
|
587 |
contenttypeinfos = simpleContent.copy() |
|
588 |
simpleContent.pop("base") |
|
1767
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
589 |
elif (basetypeinfos["type"] == COMPLEXTYPE and |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
590 |
len(basetypeinfos["elements"]) == 1 and |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
591 |
basetypeinfos["elements"][0]["name"] == "content" and |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
592 |
"elmt_type" in basetypeinfos["elements"][0] and |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
593 |
basetypeinfos["elements"][0]["elmt_type"]["type"] == SIMPLETYPE): |
814 | 594 |
contenttypeinfos = simpleContent.copy() |
595 |
contenttypeinfos["base"] = basetypeinfos["elements"][0]["elmt_type"] |
|
596 |
else: |
|
597 |
raise ValueError("No compatible base type defined for simpleContent!") |
|
598 |
contenttypeinfos = CreateSimpleType(factory, attributes, contenttypeinfos) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
599 |
|
814 | 600 |
simpleContent["elements"] = [{"name": "content", "type": ELEMENT, |
601 |
"elmt_type": contenttypeinfos, "doc": annotations, |
|
602 |
"minOccurs": 1, "maxOccurs": 1}] |
|
603 |
simpleContent["type"] = "simpleContent" |
|
604 |
return simpleContent |
|
605 |
||
606 |
||
607 |
def ReduceComplexContent(factory, attributes, elements): |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
608 |
_annotations, children = factory.ReduceElements(elements) |
814 | 609 |
complexContent = children[0].copy() |
610 |
complexContent["type"] = "complexContent" |
|
611 |
return complexContent |
|
612 |
||
613 |
||
614 |
def ReduceComplexType(factory, attributes, elements): |
|
615 |
annotations, children = factory.ReduceElements(elements) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
616 |
|
814 | 617 |
if len(children) > 0: |
618 |
if children[0]["type"] in ["simpleContent", "complexContent"]: |
|
619 |
complexType = children[0].copy() |
|
620 |
complexType.update(attributes) |
|
621 |
complexType["type"] = COMPLEXTYPE |
|
622 |
return complexType |
|
623 |
elif children[0]["type"] in ["group", "all", CHOICE, "sequence"]: |
|
624 |
complexType = {"type": COMPLEXTYPE, "elements": [], "order": True, "doc": annotations} |
|
625 |
complexType.update(attributes) |
|
626 |
group = children.pop(0) |
|
627 |
if group["type"] in ["all", "sequence"]: |
|
628 |
choice_number = 0 |
|
629 |
for element in group["elements"]: |
|
630 |
if element["type"] == CHOICE: |
|
631 |
choice_number += 1 |
|
632 |
if (group["minOccurs"] == 0 or group["maxOccurs"] != 1) and len(group["elements"]) > 1 or choice_number > 1: |
|
633 |
content = {"type": CHOICE, "name": "content", "choices": [group], "minOccurs": 1, "maxOccurs": 1} |
|
634 |
complexType["elements"].append(content) |
|
635 |
else: |
|
636 |
if len(group["elements"]) == 1: |
|
637 |
if group["minOccurs"] == 0: |
|
638 |
group["elements"][0]["minOccurs"] = group["minOccurs"] |
|
639 |
if group["maxOccurs"] != 1: |
|
640 |
group["elements"][0]["maxOccurs"] = group["maxOccurs"] |
|
641 |
for element in group["elements"]: |
|
642 |
if element["type"] == CHOICE: |
|
643 |
element["name"] = "content" |
|
644 |
complexType["elements"] = group["elements"] |
|
645 |
complexType["order"] = group["order"] |
|
646 |
elif group["type"] == CHOICE: |
|
647 |
content = group.copy() |
|
648 |
content["name"] = "content" |
|
649 |
complexType["elements"].append(content) |
|
650 |
elif group["type"] == "group": |
|
1872
866fb3ab8778
fix pylint error "(undefined-variable) Undefined variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1856
diff
changeset
|
651 |
elmtgroup = factory.FindSchemaElement(group["ref"], ELEMENTSGROUP) |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
652 |
if "elements" in elmtgroup: |
814 | 653 |
complexType["elements"] = elmtgroup["elements"] |
654 |
complexType["order"] = elmtgroup["order"] |
|
655 |
else: |
|
656 |
content = elmtgroup.copy() |
|
657 |
content["name"] = "content" |
|
658 |
complexType["elements"].append(content) |
|
659 |
else: |
|
660 |
complexType = {"elements": [], "order": True, "doc": annotations} |
|
661 |
complexType.update(attributes) |
|
662 |
complexType["type"] = COMPLEXTYPE |
|
663 |
complexType["attributes"] = ExtractAttributes(factory, children) |
|
664 |
return complexType |
|
665 |
else: |
|
666 |
raise ValueError("\"ComplexType\" can't be empty!") |
|
667 |
||
668 |
||
669 |
# Attribute elements |
|
670 |
||
671 |
def ReduceAnyAttribute(factory, attributes, elements): |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
672 |
return {"type": "anyAttribute"} |
814 | 673 |
|
674 |
||
675 |
def ReduceAttribute(factory, attributes, elements): |
|
676 |
annotations, children = factory.ReduceElements(elements) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
677 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
678 |
if "default" in attributes: |
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
679 |
if "fixed" in attributes: |
814 | 680 |
raise ValueError("\"default\" and \"fixed\" can't be defined at the same time!") |
681 |
elif attributes.get("use", "optional") != "optional": |
|
682 |
raise ValueError("if \"default\" present, \"use\" can only have the value \"optional\"!") |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
683 |
|
814 | 684 |
attribute = {"type": ATTRIBUTE, "attr_type": attributes.get("type", None), "doc": annotations} |
685 |
if len(children) > 0: |
|
686 |
if attribute["attr_type"] is None: |
|
687 |
attribute["attr_type"] = children[0] |
|
688 |
else: |
|
689 |
raise ValueError("Only one type can be defined for attribute!") |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
690 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
691 |
if "ref" in attributes: |
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
692 |
if "name" in attributes: |
814 | 693 |
raise ValueError("\"ref\" and \"name\" can't be defined at the same time!") |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
694 |
elif "form" in attributes: |
814 | 695 |
raise ValueError("\"ref\" and \"form\" can't be defined at the same time!") |
696 |
elif attribute["attr_type"] is not None: |
|
697 |
raise ValueError("if \"ref\" is present, no type can be defined!") |
|
698 |
elif attribute["attr_type"] is None: |
|
699 |
raise ValueError("No type has been defined for attribute \"%s\"!" % attributes["name"]) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
700 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
701 |
if "type" in attributes: |
814 | 702 |
tmp_attrs = attributes.copy() |
703 |
tmp_attrs.pop("type") |
|
704 |
attribute.update(tmp_attrs) |
|
705 |
else: |
|
706 |
attribute.update(attributes) |
|
707 |
return attribute |
|
708 |
||
709 |
||
710 |
def ReduceAttributeGroup(factory, attributes, elements): |
|
711 |
annotations, children = factory.ReduceElements(elements) |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
712 |
if "ref" in attributes: |
814 | 713 |
return {"type": "attributeGroup", "ref": attributes["ref"], "doc": annotations} |
714 |
else: |
|
715 |
return {"type": ATTRIBUTESGROUP, "attributes": ExtractAttributes(factory, children), "doc": annotations} |
|
716 |
||
717 |
||
718 |
# Elements groups |
|
719 |
||
720 |
def ReduceAny(factory, attributes, elements): |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
721 |
annotations, _children = factory.ReduceElements(elements) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
722 |
|
814 | 723 |
any = {"type": ANY, "doc": annotations} |
724 |
any.update(attributes) |
|
725 |
return any |
|
726 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
727 |
|
814 | 728 |
def ReduceElement(factory, attributes, elements): |
729 |
annotations, children = factory.ReduceElements(elements) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
730 |
|
814 | 731 |
types = [] |
732 |
constraints = [] |
|
733 |
for child in children: |
|
734 |
if child["type"] == CONSTRAINT: |
|
735 |
constraints.append(child) |
|
736 |
else: |
|
737 |
types.append(child) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
738 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
739 |
if "default" in attributes and "fixed" in attributes: |
814 | 740 |
raise ValueError("\"default\" and \"fixed\" can't be defined at the same time!") |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
741 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
742 |
if "ref" in attributes: |
814 | 743 |
for attr in ["name", "default", "fixed", "form", "block", "type"]: |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
744 |
if attr in attributes: |
814 | 745 |
raise ValueError("\"ref\" and \"%s\" can't be defined at the same time!" % attr) |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
746 |
if "nillable" in attributes: |
814 | 747 |
raise ValueError("\"ref\" and \"nillable\" can't be defined at the same time!") |
748 |
if len(types) > 0: |
|
749 |
raise ValueError("No type and no constraints can be defined where \"ref\" is defined!") |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
750 |
|
814 | 751 |
infos = factory.FindSchemaElement(attributes["ref"], ELEMENT) |
752 |
if infos is not None: |
|
753 |
element = infos.copy() |
|
754 |
element["constraints"] = constraints |
|
755 |
element["minOccurs"] = attributes["minOccurs"] |
|
756 |
element["maxOccurs"] = attributes["maxOccurs"] |
|
757 |
return element |
|
758 |
else: |
|
1872
866fb3ab8778
fix pylint error "(undefined-variable) Undefined variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1856
diff
changeset
|
759 |
raise ValueError("\"%s\" base type isn't defined or circular referenced!" % attributes["ref"]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
760 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
761 |
elif "name" in attributes: |
814 | 762 |
element = {"type": ELEMENT, "elmt_type": attributes.get("type", None), "constraints": constraints, "doc": annotations} |
763 |
if len(types) > 0: |
|
764 |
if element["elmt_type"] is None: |
|
765 |
element["elmt_type"] = types[0] |
|
766 |
else: |
|
767 |
raise ValueError("Only one type can be defined for attribute!") |
|
768 |
elif element["elmt_type"] is None: |
|
769 |
element["elmt_type"] = "tag" |
|
770 |
element["type"] = TAG |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
771 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
772 |
if "type" in attributes: |
814 | 773 |
tmp_attrs = attributes.copy() |
774 |
tmp_attrs.pop("type") |
|
775 |
element.update(tmp_attrs) |
|
776 |
else: |
|
777 |
element.update(attributes) |
|
778 |
return element |
|
779 |
else: |
|
780 |
raise ValueError("\"Element\" must have at least a \"ref\" or a \"name\" defined!") |
|
781 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
782 |
|
814 | 783 |
def ReduceAll(factory, attributes, elements): |
784 |
annotations, children = factory.ReduceElements(elements) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
785 |
|
814 | 786 |
for child in children: |
1849 | 787 |
if child["maxOccurs"] == "unbounded" or child["maxOccurs"] > 1: |
814 | 788 |
raise ValueError("\"all\" item can't have \"maxOccurs\" attribute greater than 1!") |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
789 |
|
814 | 790 |
return {"type": "all", "elements": children, "minOccurs": attributes["minOccurs"], |
791 |
"maxOccurs": attributes["maxOccurs"], "order": False, "doc": annotations} |
|
792 |
||
793 |
||
794 |
def ReduceChoice(factory, attributes, elements): |
|
795 |
annotations, children = factory.ReduceElements(elements) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
796 |
|
814 | 797 |
choices = [] |
798 |
for child in children: |
|
799 |
if child["type"] in [ELEMENT, ANY, TAG]: |
|
800 |
choices.append(child) |
|
801 |
elif child["type"] == "sequence": |
|
802 |
child["minOccurs"] = child["maxOccurs"] = 1 |
|
803 |
choices.append(child) |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
804 |
# raise ValueError("\"sequence\" in \"choice\" is not supported. Create instead a new complex type!") |
814 | 805 |
elif child["type"] == CHOICE: |
806 |
choices.extend(child["choices"]) |
|
807 |
elif child["type"] == "group": |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
808 |
elmtgroup = factory.FindSchemaElement(child["ref"], ELEMENTSGROUP) |
1775
b45f2768fab1
clean-up: fix PEP8 E713 test for membership should be 'not in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1774
diff
changeset
|
809 |
if "choices" not in elmtgroup: |
814 | 810 |
raise ValueError("Only group composed of \"choice\" can be referenced in \"choice\" element!") |
811 |
choices_tmp = [] |
|
812 |
for choice in elmtgroup["choices"]: |
|
3752 | 813 |
if not isinstance(choice["elmt_type"], str) and choice["elmt_type"]["type"] == COMPLEXTYPE: |
814 | 814 |
elmt_type = "%s_%s" % (elmtgroup["name"], choice["name"]) |
815 |
if factory.TargetNamespace is not None: |
|
816 |
elmt_type = "%s:%s" % (factory.TargetNamespace, elmt_type) |
|
817 |
new_choice = choice.copy() |
|
818 |
new_choice["elmt_type"] = elmt_type |
|
819 |
choices_tmp.append(new_choice) |
|
820 |
else: |
|
821 |
choices_tmp.append(choice) |
|
822 |
choices.extend(choices_tmp) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
823 |
|
814 | 824 |
for choice in choices: |
825 |
attributes["minOccurs"] = min(attributes["minOccurs"], choice["minOccurs"]) |
|
826 |
choice["minOccurs"] = 1 |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
827 |
|
814 | 828 |
return {"type": CHOICE, "choices": choices, "minOccurs": attributes["minOccurs"], |
829 |
"maxOccurs": attributes["maxOccurs"], "doc": annotations} |
|
830 |
||
831 |
||
832 |
def ReduceSequence(factory, attributes, elements): |
|
833 |
annotations, children = factory.ReduceElements(elements) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
834 |
|
814 | 835 |
sequence = [] |
836 |
for child in children: |
|
837 |
if child["type"] in [ELEMENT, ANY, TAG, CHOICE]: |
|
838 |
sequence.append(child) |
|
839 |
elif child["type"] == "sequence": |
|
840 |
sequence.extend(child["elements"]) |
|
841 |
elif child["type"] == "group": |
|
842 |
elmtgroup = factory.FindSchemaElement(child["ref"], ELEMENTSGROUP) |
|
1775
b45f2768fab1
clean-up: fix PEP8 E713 test for membership should be 'not in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1774
diff
changeset
|
843 |
if "elements" not in elmtgroup or not elmtgroup["order"]: |
814 | 844 |
raise ValueError("Only group composed of \"sequence\" can be referenced in \"sequence\" element!") |
845 |
elements_tmp = [] |
|
846 |
for element in elmtgroup["elements"]: |
|
3752 | 847 |
if not isinstance(element["elmt_type"], str) and element["elmt_type"]["type"] == COMPLEXTYPE: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
848 |
elmt_type = "%s_%s" % (elmtgroup["name"], element["name"]) |
814 | 849 |
if factory.TargetNamespace is not None: |
850 |
elmt_type = "%s:%s" % (factory.TargetNamespace, elmt_type) |
|
851 |
new_element = element.copy() |
|
852 |
new_element["elmt_type"] = elmt_type |
|
853 |
elements_tmp.append(new_element) |
|
854 |
else: |
|
855 |
elements_tmp.append(element) |
|
856 |
sequence.extend(elements_tmp) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
857 |
|
814 | 858 |
return {"type": "sequence", "elements": sequence, "minOccurs": attributes["minOccurs"], |
859 |
"maxOccurs": attributes["maxOccurs"], "order": True, "doc": annotations} |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
860 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
861 |
|
814 | 862 |
def ReduceGroup(factory, attributes, elements): |
863 |
annotations, children = factory.ReduceElements(elements) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
864 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
865 |
if "ref" in attributes: |
814 | 866 |
return {"type": "group", "ref": attributes["ref"], "doc": annotations} |
867 |
else: |
|
868 |
element = children[0] |
|
869 |
group = {"type": ELEMENTSGROUP, "doc": annotations} |
|
870 |
if element["type"] == CHOICE: |
|
871 |
group["choices"] = element["choices"] |
|
872 |
else: |
|
1683
57b4ac796dcb
fix reducing groups with ordered elements
Surkov Sergey <surkovsv93@gmail.com>
parents:
1571
diff
changeset
|
873 |
group.update({"elements": element["elements"], "order": element["order"]}) |
814 | 874 |
group.update(attributes) |
875 |
return group |
|
876 |
||
877 |
# Constraint elements |
|
878 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
879 |
|
814 | 880 |
def ReduceUnique(factory, attributes, elements): |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
881 |
_annotations, children = factory.ReduceElements(elements) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
882 |
|
814 | 883 |
unique = {"type": CONSTRAINT, "const_type": "unique", "selector": children[0], "fields": children[1:]} |
884 |
unique.update(attributes) |
|
885 |
return unique |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
886 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
887 |
|
814 | 888 |
def ReduceKey(factory, attributes, elements): |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
889 |
_annotations, children = factory.ReduceElements(elements) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
890 |
|
814 | 891 |
key = {"type": CONSTRAINT, "const_type": "key", "selector": children[0], "fields": children[1:]} |
892 |
key.update(attributes) |
|
893 |
return key |
|
894 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
895 |
|
814 | 896 |
def ReduceKeyRef(factory, attributes, elements): |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
897 |
_annotations, children = factory.ReduceElements(elements) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
898 |
|
814 | 899 |
keyref = {"type": CONSTRAINT, "const_type": "keyref", "selector": children[0], "fields": children[1:]} |
900 |
keyref.update(attributes) |
|
901 |
return keyref |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
902 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
903 |
|
814 | 904 |
def ReduceSelector(factory, attributes, elements): |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
905 |
factory.ReduceElements(elements) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
906 |
|
814 | 907 |
selector = {"type": CONSTRAINT, "const_type": "selector"} |
908 |
selector.update(attributes) |
|
909 |
return selector |
|
910 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
911 |
|
814 | 912 |
def ReduceField(factory, attributes, elements): |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
913 |
factory.ReduceElements(elements) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
914 |
|
814 | 915 |
field = {"type": CONSTRAINT, "const_type": "field"} |
916 |
field.update(attributes) |
|
917 |
return field |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
918 |
|
814 | 919 |
|
920 |
# Inclusion elements |
|
921 |
||
922 |
def ReduceImport(factory, attributes, elements): |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
923 |
factory.ReduceElements(elements) |
814 | 924 |
raise ValueError("\"import\" element isn't supported yet!") |
925 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
926 |
|
814 | 927 |
def ReduceInclude(factory, attributes, elements): |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
928 |
factory.ReduceElements(elements) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
929 |
|
814 | 930 |
if factory.FileName is None: |
931 |
raise ValueError("Include in XSD string not yet supported") |
|
932 |
filepath = attributes["schemaLocation"] |
|
933 |
if filepath is not None and not os.path.exists(filepath): |
|
934 |
filepath = os.path.join(factory.BaseFolder, filepath) |
|
935 |
if not os.path.exists(filepath): |
|
936 |
raise ValueError("No file '%s' found for include" % attributes["schemaLocation"]) |
|
937 |
xsdfile = open(filepath, 'r') |
|
938 |
include_factory = XSDClassFactory(minidom.parse(xsdfile), filepath) |
|
939 |
xsdfile.close() |
|
940 |
include_factory.CreateClasses() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
941 |
|
814 | 942 |
if factory.TargetNamespace == include_factory.TargetNamespace: |
943 |
factory.Namespaces[factory.TargetNamespace].update(include_factory.Namespaces[include_factory.TargetNamespace]) |
|
944 |
else: |
|
945 |
factory.Namespaces[include_factory.TargetNamespace] = include_factory.Namespaces[include_factory.TargetNamespace] |
|
946 |
factory.ComputedClasses.update(include_factory.ComputedClasses) |
|
1322
0a9227f743b3
Fixed xmlclass for working with included files, adding support for SimpleType elements and solving ambiguity in extension class when different elements share the same name and parent name
Laurent Bessard
parents:
1315
diff
changeset
|
947 |
factory.ComputedClassesLookUp.update(include_factory.ComputedClassesLookUp) |
0a9227f743b3
Fixed xmlclass for working with included files, adding support for SimpleType elements and solving ambiguity in extension class when different elements share the same name and parent name
Laurent Bessard
parents:
1315
diff
changeset
|
948 |
factory.EquivalentClassesParent.update(include_factory.EquivalentClassesParent) |
814 | 949 |
return None |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
950 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
951 |
|
814 | 952 |
def ReduceRedefine(factory, attributes, elements): |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
953 |
factory.ReduceElements(elements) |
814 | 954 |
raise ValueError("\"redefine\" element isn't supported yet!") |
955 |
||
956 |
||
957 |
# Schema element |
|
958 |
||
959 |
def ReduceSchema(factory, attributes, elements): |
|
960 |
factory.AttributeFormDefault = attributes["attributeFormDefault"] |
|
961 |
factory.ElementFormDefault = attributes["elementFormDefault"] |
|
962 |
factory.BlockDefault = attributes["blockDefault"] |
|
963 |
factory.FinalDefault = attributes["finalDefault"] |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
964 |
|
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1290
diff
changeset
|
965 |
targetNamespace = attributes.get("targetNamespace", None) |
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1290
diff
changeset
|
966 |
factory.TargetNamespace = factory.DefinedNamespaces.get(targetNamespace, None) |
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
967 |
if factory.TargetNamespace is not None: |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1290
diff
changeset
|
968 |
factory.etreeNamespaceFormat = "{%s}%%s" % targetNamespace |
814 | 969 |
factory.Namespaces[factory.TargetNamespace] = {} |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
970 |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
971 |
_annotations, children = factory.ReduceElements(elements, True) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
972 |
|
814 | 973 |
for child in children: |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
974 |
if "name" in child: |
814 | 975 |
infos = factory.GetQualifiedNameInfos(child["name"], factory.TargetNamespace, True) |
976 |
if infos is None: |
|
977 |
factory.Namespaces[factory.TargetNamespace][child["name"]] = child |
|
978 |
elif not CompareSchema(infos, child): |
|
979 |
raise ValueError("\"%s\" is defined twice in targetNamespace!" % child["name"]) |
|
980 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
981 |
|
814 | 982 |
def CompareSchema(schema, reference): |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
983 |
if isinstance(schema, list): |
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
984 |
if not isinstance(reference, list) or len(schema) != len(reference): |
814 | 985 |
return False |
986 |
for i, value in enumerate(schema): |
|
987 |
result = CompareSchema(value, reference[i]) |
|
988 |
if not result: |
|
989 |
return result |
|
990 |
return True |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
991 |
elif isinstance(schema, dict): |
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
992 |
if not isinstance(reference, dict) or len(schema) != len(reference): |
814 | 993 |
return False |
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
994 |
for name, value in list(schema.items()): |
814 | 995 |
ref_value = reference.get(name, None) |
1743
c3c3d1318130
clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1740
diff
changeset
|
996 |
if ref_value is None and value is not None: |
814 | 997 |
return False |
998 |
result = CompareSchema(value, ref_value) |
|
999 |
if not result: |
|
1000 |
return result |
|
1001 |
return True |
|
1002 |
elif isinstance(schema, FunctionType): |
|
1003 |
if not isinstance(reference, FunctionType) or schema.__name__ != reference.__name__: |
|
1004 |
return False |
|
1005 |
else: |
|
1006 |
return True |
|
1007 |
return schema == reference |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1008 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
1009 |
|
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
1010 |
# ------------------------------------------------------------------------------- |
814 | 1011 |
# Base class for XSD schema extraction |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
1012 |
# ------------------------------------------------------------------------------- |
814 | 1013 |
|
1014 |
||
1015 |
class XSDClassFactory(ClassFactory): |
|
1016 |
||
1017 |
def __init__(self, document, filepath=None, debug=False): |
|
1018 |
ClassFactory.__init__(self, document, filepath, debug) |
|
1019 |
self.Namespaces["xml"] = { |
|
1020 |
"lang": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1021 |
"type": SYNTAXATTRIBUTE, |
814 | 1022 |
"extract": { |
1023 |
"default": GenerateModelNameExtraction("lang", LANGUAGE_model) |
|
1024 |
} |
|
1025 |
} |
|
1026 |
} |
|
1027 |
self.Namespaces["xsi"] = { |
|
1028 |
"noNamespaceSchemaLocation": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1029 |
"type": SYNTAXATTRIBUTE, |
814 | 1030 |
"extract": { |
1031 |
"default": NotSupportedYet("noNamespaceSchemaLocation") |
|
1032 |
} |
|
1033 |
}, |
|
1034 |
"nil": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1035 |
"type": SYNTAXATTRIBUTE, |
814 | 1036 |
"extract": { |
1037 |
"default": NotSupportedYet("nil") |
|
1038 |
} |
|
1039 |
}, |
|
1040 |
"schemaLocation": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1041 |
"type": SYNTAXATTRIBUTE, |
814 | 1042 |
"extract": { |
1043 |
"default": NotSupportedYet("schemaLocation") |
|
1044 |
} |
|
1045 |
}, |
|
1046 |
"type": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1047 |
"type": SYNTAXATTRIBUTE, |
814 | 1048 |
"extract": { |
1049 |
"default": NotSupportedYet("type") |
|
1050 |
} |
|
1051 |
} |
|
1052 |
} |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1053 |
|
814 | 1054 |
def ParseSchema(self): |
1055 |
for child in self.Document.childNodes: |
|
1056 |
if child.nodeType == self.Document.ELEMENT_NODE: |
|
1057 |
schema = child |
|
1058 |
break |
|
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
1059 |
for qualified_name, attr in list(schema._attrs.items()): |
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1060 |
namespace, name = DecomposeQualifiedName(qualified_name) |
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1061 |
if namespace == "xmlns": |
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1062 |
value = GetAttributeValue(attr) |
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1063 |
self.DefinedNamespaces[value] = name |
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1064 |
self.NSMAP[name] = value |
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1065 |
if value == "http://www.w3.org/2001/XMLSchema": |
814 | 1066 |
self.SchemaNamespace = name |
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1067 |
self.Namespaces[self.SchemaNamespace] = XSD_NAMESPACE |
814 | 1068 |
self.Schema = XSD_NAMESPACE["schema"]["extract"]["default"](self, schema) |
1069 |
ReduceSchema(self, self.Schema[1], self.Schema[2]) |
|
1070 |
||
1071 |
def FindSchemaElement(self, element_name, element_type=None): |
|
1072 |
namespace, name = DecomposeQualifiedName(element_name) |
|
1073 |
element = self.GetQualifiedNameInfos(name, namespace, True) |
|
1074 |
if element is None and namespace == self.TargetNamespace and name not in self.CurrentCompilations: |
|
1075 |
self.CurrentCompilations.append(name) |
|
1076 |
element = self.CreateSchemaElement(name, element_type) |
|
1077 |
self.CurrentCompilations.pop(-1) |
|
1078 |
if element is not None: |
|
1079 |
self.Namespaces[self.TargetNamespace][name] = element |
|
1080 |
if element is None: |
|
1081 |
if name in self.CurrentCompilations: |
|
1082 |
if self.Debug: |
|
1826
91796f408540
fix usage of python2-only print statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
1083 |
print("Warning : \"%s\" is circular referenced!" % element_name) |
814 | 1084 |
else: |
1085 |
raise ValueError("\"%s\" isn't defined!" % element_name) |
|
1086 |
if element_type is not None and element["type"] != element_type: |
|
1087 |
raise ValueError("\"%s\" isn't of the expected type!" % element_name) |
|
1088 |
return element |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1089 |
|
814 | 1090 |
def CreateSchemaElement(self, element_name, element_type): |
1091 |
for type, attributes, elements in self.Schema[2]: |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
1092 |
_namespace, name = DecomposeQualifiedName(type) |
814 | 1093 |
if attributes.get("name", None) == element_name: |
1094 |
element_infos = None |
|
1095 |
if element_type in (ATTRIBUTE, None) and name == "attribute": |
|
1096 |
element_infos = ReduceAttribute(self, attributes, elements) |
|
1097 |
elif element_type in (ELEMENT, None) and name == "element": |
|
1098 |
element_infos = ReduceElement(self, attributes, elements) |
|
1099 |
elif element_type in (ATTRIBUTESGROUP, None) and name == "attributeGroup": |
|
1100 |
element_infos = ReduceAttributeGroup(self, attributes, elements) |
|
1101 |
elif element_type in (ELEMENTSGROUP, None) and name == "group": |
|
1102 |
element_infos = ReduceGroup(self, attributes, elements) |
|
1103 |
elif element_type in (SIMPLETYPE, None) and name == "simpleType": |
|
1104 |
element_infos = ReduceSimpleType(self, attributes, elements) |
|
1105 |
elif element_type in (COMPLEXTYPE, None) and name == "complexType": |
|
1106 |
element_infos = ReduceComplexType(self, attributes, elements) |
|
1107 |
if element_infos is not None: |
|
1108 |
self.Namespaces[self.TargetNamespace][element_name] = element_infos |
|
1109 |
return element_infos |
|
1110 |
return None |
|
1111 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1112 |
|
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1113 |
def GenerateParserFromXSD(filepath): |
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1114 |
""" |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1115 |
This function opens the xsd file and generate a xml parser with class lookup from |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1116 |
the xml tree |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1117 |
""" |
814 | 1118 |
xsdfile = open(filepath, 'r') |
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1119 |
xsdstring = xsdfile.read() |
814 | 1120 |
xsdfile.close() |
1322
0a9227f743b3
Fixed xmlclass for working with included files, adding support for SimpleType elements and solving ambiguity in extension class when different elements share the same name and parent name
Laurent Bessard
parents:
1315
diff
changeset
|
1121 |
cwd = os.getcwd() |
0a9227f743b3
Fixed xmlclass for working with included files, adding support for SimpleType elements and solving ambiguity in extension class when different elements share the same name and parent name
Laurent Bessard
parents:
1315
diff
changeset
|
1122 |
os.chdir(os.path.dirname(filepath)) |
0a9227f743b3
Fixed xmlclass for working with included files, adding support for SimpleType elements and solving ambiguity in extension class when different elements share the same name and parent name
Laurent Bessard
parents:
1315
diff
changeset
|
1123 |
parser = GenerateParser(XSDClassFactory(minidom.parseString(xsdstring), filepath), xsdstring) |
0a9227f743b3
Fixed xmlclass for working with included files, adding support for SimpleType elements and solving ambiguity in extension class when different elements share the same name and parent name
Laurent Bessard
parents:
1315
diff
changeset
|
1124 |
os.chdir(cwd) |
0a9227f743b3
Fixed xmlclass for working with included files, adding support for SimpleType elements and solving ambiguity in extension class when different elements share the same name and parent name
Laurent Bessard
parents:
1315
diff
changeset
|
1125 |
return parser |
814 | 1126 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1127 |
|
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1128 |
def GenerateParserFromXSDstring(xsdstring): |
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1129 |
""" |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1130 |
This function generate a xml from the xsd given as a string |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1131 |
""" |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1290
diff
changeset
|
1132 |
return GenerateParser(XSDClassFactory(minidom.parseString(xsdstring)), xsdstring) |
814 | 1133 |
|
1134 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
1135 |
# ------------------------------------------------------------------------------- |
814 | 1136 |
# XSD schema syntax elements |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
1137 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
1138 |
|
814 | 1139 |
|
1140 |
XSD_NAMESPACE = { |
|
1141 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
1142 |
# ------------------------------------------------------------------------------- |
1776
81aa8aaccdd4
clean-up: fix PEP8 E122 continuation line missing indentation or outdented
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1143 |
# Syntax elements definition |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
1144 |
# ------------------------------------------------------------------------------- |
814 | 1145 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1146 |
"all": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1147 |
"struct": """ |
814 | 1148 |
<all |
1149 |
id = ID |
|
1150 |
maxOccurs = 1 : 1 |
|
1151 |
minOccurs = (0 | 1) : 1 |
|
1152 |
{any attributes with non-schema namespace . . .}> |
|
1153 |
Content: (annotation?, element*) |
|
1154 |
</all>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1155 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1156 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1157 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1158 |
"all", ["id", "maxOccurs", "minOccurs"], |
814 | 1159 |
re.compile("((?:annotation )?(?:element )*)")) |
1160 |
}, |
|
1161 |
"reduce": ReduceAll |
|
1162 |
}, |
|
1163 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1164 |
"annotation": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1165 |
"struct": """ |
814 | 1166 |
<annotation |
1167 |
id = ID |
|
1168 |
{any attributes with non-schema namespace . . .}> |
|
1169 |
Content: (appinfo | documentation)* |
|
1170 |
</annotation>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1171 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1172 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1173 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1174 |
"annotation", ["id"], |
814 | 1175 |
re.compile("((?:app_info |documentation )*)")) |
1176 |
}, |
|
1177 |
"reduce": ReduceAnnotation |
|
1178 |
}, |
|
1179 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1180 |
"any": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1181 |
"struct": """ |
814 | 1182 |
<any |
1183 |
id = ID |
|
1184 |
maxOccurs = (nonNegativeInteger | unbounded) : 1 |
|
1185 |
minOccurs = nonNegativeInteger : 1 |
|
1186 |
namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any |
|
1187 |
processContents = (lax | skip | strict) : strict |
|
1188 |
{any attributes with non-schema namespace . . .}> |
|
1189 |
Content: (annotation?) |
|
1190 |
</any>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1191 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1192 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1193 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1194 |
"any", |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1195 |
["id", "maxOccurs", "minOccurs", "namespace", "processContents"], |
814 | 1196 |
re.compile("((?:annotation )?(?:simpleType )*)")) |
1197 |
}, |
|
1198 |
"reduce": ReduceAny |
|
1199 |
}, |
|
1200 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1201 |
"anyAttribute": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1202 |
"struct": """ |
814 | 1203 |
<anyAttribute |
1204 |
id = ID |
|
1205 |
namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any |
|
1206 |
processContents = (lax | skip | strict) : strict |
|
1207 |
{any attributes with non-schema namespace . . .}> |
|
1208 |
Content: (annotation?) |
|
1209 |
</anyAttribute>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1210 |
"type": SYNTAXELEMENT, |
814 | 1211 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1212 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1213 |
"anyAttribute", ["id", "namespace", "processContents"], ONLY_ANNOTATION) |
814 | 1214 |
}, |
1215 |
"reduce": ReduceAnyAttribute |
|
1216 |
}, |
|
1217 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1218 |
"appinfo": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1219 |
"struct": """ |
814 | 1220 |
<appinfo |
1221 |
source = anyURI |
|
1222 |
{any attributes with non-schema namespace . . .}> |
|
1223 |
Content: ({any})* |
|
1224 |
</appinfo>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1225 |
"type": SYNTAXELEMENT, |
814 | 1226 |
"extract": { |
1227 |
"default": GenerateElement("appinfo", ["source"], re.compile("(.*)"), True) |
|
1228 |
}, |
|
1229 |
"reduce": ReduceAppInfo |
|
1230 |
}, |
|
1231 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1232 |
"attribute": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1233 |
"struct": """ |
814 | 1234 |
<attribute |
1235 |
default = string |
|
1236 |
fixed = string |
|
1237 |
form = (qualified | unqualified) |
|
1238 |
id = ID |
|
1239 |
name = NCName |
|
1240 |
ref = QName |
|
1241 |
type = QName |
|
1242 |
use = (optional | prohibited | required) : optional |
|
1243 |
{any attributes with non-schema namespace . . .}> |
|
1244 |
Content: (annotation?, simpleType?) |
|
1245 |
</attribute>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1246 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1247 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1248 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1249 |
"attribute", |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1250 |
["default", "fixed", "form", "id", "name", "ref", "type", "use"], |
814 | 1251 |
re.compile("((?:annotation )?(?:simpleType )?)")), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1252 |
"schema": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1253 |
"attribute", |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1254 |
["default", "fixed", "form", "id", "name", "type"], |
814 | 1255 |
re.compile("((?:annotation )?(?:simpleType )?)")) |
1256 |
}, |
|
1257 |
"reduce": ReduceAttribute |
|
1258 |
}, |
|
1259 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1260 |
"attributeGroup": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1261 |
"struct": """ |
814 | 1262 |
<attributeGroup |
1263 |
id = ID |
|
1264 |
name = NCName |
|
1265 |
ref = QName |
|
1266 |
{any attributes with non-schema namespace . . .}> |
|
1267 |
Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?)) |
|
1268 |
</attributeGroup>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1269 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1270 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1271 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1272 |
"attributeGroup", |
814 | 1273 |
["id", "ref"], ONLY_ANNOTATION), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1274 |
"schema": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1275 |
"attributeGroup", |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1276 |
["id", "name"], |
814 | 1277 |
re.compile("((?:annotation )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")) |
1278 |
}, |
|
1279 |
"reduce": ReduceAttributeGroup |
|
1280 |
}, |
|
1281 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1282 |
"choice": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1283 |
"struct": """ |
814 | 1284 |
<choice |
1285 |
id = ID |
|
1286 |
maxOccurs = (nonNegativeInteger | unbounded) : 1 |
|
1287 |
minOccurs = nonNegativeInteger : 1 |
|
1288 |
{any attributes with non-schema namespace . . .}> |
|
1289 |
Content: (annotation?, (element | group | choice | sequence | any)*) |
|
1290 |
</choice>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1291 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1292 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1293 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1294 |
"choice", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1295 |
["id", "maxOccurs", "minOccurs"], |
814 | 1296 |
re.compile("((?:annotation )?(?:element |group |choice |sequence |any )*)")) |
1297 |
}, |
|
1298 |
"reduce": ReduceChoice |
|
1299 |
}, |
|
1300 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1301 |
"complexContent": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1302 |
"struct": """ |
814 | 1303 |
<complexContent |
1304 |
id = ID |
|
1305 |
mixed = boolean |
|
1306 |
{any attributes with non-schema namespace . . .}> |
|
1307 |
Content: (annotation?, (restriction | extension)) |
|
1308 |
</complexContent>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1309 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1310 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1311 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1312 |
"complexContent", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1313 |
["id", "mixed"], |
814 | 1314 |
re.compile("((?:annotation )?(?:restriction |extension ))")) |
1315 |
}, |
|
1316 |
"reduce": ReduceComplexContent |
|
1317 |
}, |
|
1318 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1319 |
"complexType": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1320 |
"struct": """ |
814 | 1321 |
<complexType |
1322 |
abstract = boolean : false |
|
1323 |
block = (#all | List of (extension | restriction)) |
|
1324 |
final = (#all | List of (extension | restriction)) |
|
1325 |
id = ID |
|
1326 |
mixed = boolean : false |
|
1327 |
name = NCName |
|
1328 |
{any attributes with non-schema namespace . . .}> |
|
1329 |
Content: (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))) |
|
1330 |
</complexType>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1331 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1332 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1333 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1334 |
"complexType", |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1335 |
["abstract", "block", "final", "id", "mixed", "name"], |
814 | 1336 |
re.compile("((?:annotation )?(?:simpleContent |complexContent |(?:(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))))")) |
1337 |
}, |
|
1338 |
"reduce": ReduceComplexType |
|
1339 |
}, |
|
1340 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1341 |
"documentation": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1342 |
"struct": """ |
814 | 1343 |
<documentation |
1344 |
source = anyURI |
|
1345 |
xml:lang = language |
|
1346 |
{any attributes with non-schema namespace . . .}> |
|
1347 |
Content: ({any})* |
|
1348 |
</documentation>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1349 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1350 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1351 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1352 |
"documentation", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1353 |
["source", "lang"], |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1354 |
re.compile("(.*)"), True) |
814 | 1355 |
}, |
1356 |
"reduce": ReduceDocumentation |
|
1357 |
}, |
|
1358 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1359 |
"element": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1360 |
"struct": """ |
814 | 1361 |
<element |
1362 |
abstract = boolean : false |
|
1363 |
block = (#all | List of (extension | restriction | substitution)) |
|
1364 |
default = string |
|
1365 |
final = (#all | List of (extension | restriction)) |
|
1366 |
fixed = string |
|
1367 |
form = (qualified | unqualified) |
|
1368 |
id = ID |
|
1369 |
maxOccurs = (nonNegativeInteger | unbounded) : 1 |
|
1370 |
minOccurs = nonNegativeInteger : 1 |
|
1371 |
name = NCName |
|
1372 |
nillable = boolean : false |
|
1373 |
ref = QName |
|
1374 |
substitutionGroup = QName |
|
1375 |
type = QName |
|
1376 |
{any attributes with non-schema namespace . . .}> |
|
1377 |
Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*)) |
|
1378 |
</element>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1379 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1380 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1381 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1382 |
"element", |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1383 |
["abstract", "block", "default", "final", "fixed", "form", "id", "maxOccurs", "minOccurs", "name", "nillable", "ref", "substitutionGroup", "type"], |
814 | 1384 |
re.compile("((?:annotation )?(?:simpleType |complexType )?(?:unique |key |keyref )*)")), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1385 |
"schema": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1386 |
"element", |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1387 |
["abstract", "block", "default", "final", "fixed", "form", "id", "name", "nillable", "substitutionGroup", "type"], |
814 | 1388 |
re.compile("((?:annotation )?(?:simpleType |complexType )?(?:unique |key |keyref )*)")) |
1389 |
}, |
|
1390 |
"reduce": ReduceElement |
|
1391 |
}, |
|
1392 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1393 |
"enumeration": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1394 |
"struct": """ |
814 | 1395 |
<enumeration |
1396 |
id = ID |
|
1397 |
value = anySimpleType |
|
1398 |
{any attributes with non-schema namespace . . .}> |
|
1399 |
Content: (annotation?) |
|
1400 |
</enumeration>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1401 |
"type": SYNTAXELEMENT, |
814 | 1402 |
"extract": { |
1403 |
"default": GenerateElement("enumeration", ["id", "value"], ONLY_ANNOTATION) |
|
1404 |
}, |
|
1405 |
"reduce": GenerateFacetReducing("enumeration", False) |
|
1406 |
}, |
|
1407 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1408 |
"extension": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1409 |
"struct": """ |
814 | 1410 |
<extension |
1411 |
base = QName |
|
1412 |
id = ID |
|
1413 |
{any attributes with non-schema namespace . . .}> |
|
1414 |
Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))) |
|
1415 |
</extension>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1416 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1417 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1418 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1419 |
"extension", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1420 |
["base", "id"], |
814 | 1421 |
re.compile("((?:annotation )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1422 |
"complexContent": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1423 |
"extension", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1424 |
["base", "id"], |
814 | 1425 |
re.compile("((?:annotation )?(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")) |
1426 |
}, |
|
1427 |
"reduce": ReduceExtension |
|
1428 |
}, |
|
1429 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1430 |
"field": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1431 |
"struct": """ |
814 | 1432 |
<field |
1433 |
id = ID |
|
1434 |
xpath = a subset of XPath expression, see below |
|
1435 |
{any attributes with non-schema namespace . . .}> |
|
1436 |
Content: (annotation?) |
|
1437 |
</field>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1438 |
"type": SYNTAXELEMENT, |
814 | 1439 |
"extract": { |
1440 |
"default": GenerateElement("field", ["id", "xpath"], ONLY_ANNOTATION) |
|
1441 |
}, |
|
1442 |
"reduce": ReduceField |
|
1443 |
}, |
|
1444 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1445 |
"fractionDigits": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1446 |
"struct": """ |
814 | 1447 |
<fractionDigits |
1448 |
fixed = boolean : false |
|
1449 |
id = ID |
|
1450 |
value = nonNegativeInteger |
|
1451 |
{any attributes with non-schema namespace . . .}> |
|
1452 |
Content: (annotation?) |
|
1453 |
</fractionDigits>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1454 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1455 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1456 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1457 |
"fractionDigits", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1458 |
["fixed", "id", "value"], |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1459 |
ONLY_ANNOTATION) |
814 | 1460 |
}, |
1461 |
"reduce": GenerateFacetReducing("fractionDigits", True) |
|
1462 |
}, |
|
1463 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1464 |
"group": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1465 |
"struct": """ |
814 | 1466 |
<group |
1467 |
id = ID |
|
1468 |
maxOccurs = (nonNegativeInteger | unbounded) : 1 |
|
1469 |
minOccurs = nonNegativeInteger : 1 |
|
1470 |
name = NCName |
|
1471 |
ref = QName |
|
1472 |
{any attributes with non-schema namespace . . .}> |
|
1473 |
Content: (annotation?, (all | choice | sequence)?) |
|
1474 |
</group>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1475 |
"type": SYNTAXELEMENT, |
814 | 1476 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1477 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1478 |
"group", |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1479 |
["id", "maxOccurs", "minOccurs", "ref"], |
814 | 1480 |
re.compile("((?:annotation )?(?:all |choice |sequence )?)")), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1481 |
"schema": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1482 |
"group", |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1483 |
["id", "name"], |
814 | 1484 |
re.compile("((?:annotation )?(?:all |choice |sequence )?)")) |
1485 |
}, |
|
1486 |
"reduce": ReduceGroup |
|
1487 |
}, |
|
1488 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1489 |
"import": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1490 |
"struct": """ |
814 | 1491 |
<import |
1492 |
id = ID |
|
1493 |
namespace = anyURI |
|
1494 |
schemaLocation = anyURI |
|
1495 |
{any attributes with non-schema namespace . . .}> |
|
1496 |
Content: (annotation?) |
|
1497 |
</import>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1498 |
"type": SYNTAXELEMENT, |
814 | 1499 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1500 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1501 |
"import", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1502 |
["id", "namespace", "schemaLocation"], |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1503 |
ONLY_ANNOTATION) |
814 | 1504 |
}, |
1505 |
"reduce": ReduceImport |
|
1506 |
}, |
|
1507 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1508 |
"include": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1509 |
"struct": """ |
814 | 1510 |
<include |
1511 |
id = ID |
|
1512 |
schemaLocation = anyURI |
|
1513 |
{any attributes with non-schema namespace . . .}> |
|
1514 |
Content: (annotation?) |
|
1515 |
</include>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1516 |
"type": SYNTAXELEMENT, |
814 | 1517 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1518 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1519 |
"include", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1520 |
["id", "schemaLocation"], |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1521 |
ONLY_ANNOTATION) |
814 | 1522 |
}, |
1523 |
"reduce": ReduceInclude |
|
1524 |
}, |
|
1525 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1526 |
"key": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1527 |
"struct": """ |
814 | 1528 |
<key |
1529 |
id = ID |
|
1530 |
name = NCName |
|
1531 |
{any attributes with non-schema namespace . . .}> |
|
1532 |
Content: (annotation?, (selector, field+)) |
|
1533 |
</key>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1534 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1535 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1536 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1537 |
"key", ["id", "name"], |
814 | 1538 |
re.compile("((?:annotation )?(?:selector (?:field )+))")) |
1539 |
}, |
|
1540 |
"reduce": ReduceKey |
|
1541 |
}, |
|
1542 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1543 |
"keyref": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1544 |
"struct": """ |
814 | 1545 |
<keyref |
1546 |
id = ID |
|
1547 |
name = NCName |
|
1548 |
refer = QName |
|
1549 |
{any attributes with non-schema namespace . . .}> |
|
1550 |
Content: (annotation?, (selector, field+)) |
|
1551 |
</keyref>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1552 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1553 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1554 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1555 |
"keyref", ["id", "name", "refer"], |
814 | 1556 |
re.compile("((?:annotation )?(?:selector (?:field )+))")) |
1557 |
}, |
|
1558 |
"reduce": ReduceKeyRef |
|
1559 |
}, |
|
1560 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1561 |
"length": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1562 |
"struct": """ |
814 | 1563 |
<length |
1564 |
fixed = boolean : false |
|
1565 |
id = ID |
|
1566 |
value = nonNegativeInteger |
|
1567 |
{any attributes with non-schema namespace . . .}> |
|
1568 |
Content: (annotation?) |
|
1569 |
</length>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1570 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1571 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1572 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1573 |
"length", ["fixed", "id", "value"], ONLY_ANNOTATION) |
814 | 1574 |
}, |
1575 |
"reduce": GenerateFacetReducing("length", True) |
|
1576 |
}, |
|
1577 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1578 |
"list": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1579 |
"struct": """ |
814 | 1580 |
<list |
1581 |
id = ID |
|
1582 |
itemType = QName |
|
1583 |
{any attributes with non-schema namespace . . .}> |
|
1584 |
Content: (annotation?, simpleType?) |
|
1585 |
</list>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1586 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1587 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1588 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1589 |
"list", ["id", "itemType"], |
814 | 1590 |
re.compile("((?:annotation )?(?:simpleType )?)$")) |
1591 |
}, |
|
1592 |
"reduce": ReduceList |
|
1593 |
}, |
|
1594 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1595 |
"maxExclusive": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1596 |
"struct": """ |
814 | 1597 |
<maxInclusive |
1598 |
fixed = boolean : false |
|
1599 |
id = ID |
|
1600 |
value = anySimpleType |
|
1601 |
{any attributes with non-schema namespace . . .}> |
|
1602 |
Content: (annotation?) |
|
1603 |
</maxInclusive>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1604 |
"type": SYNTAXELEMENT, |
814 | 1605 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1606 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1607 |
"maxExclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) |
814 | 1608 |
}, |
1609 |
"reduce": GenerateFacetReducing("maxExclusive", True) |
|
1610 |
}, |
|
1611 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1612 |
"maxInclusive": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1613 |
"struct": """ |
814 | 1614 |
<maxExclusive |
1615 |
fixed = boolean : false |
|
1616 |
id = ID |
|
1617 |
value = anySimpleType |
|
1618 |
{any attributes with non-schema namespace . . .}> |
|
1619 |
Content: (annotation?) |
|
1620 |
</maxExclusive>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1621 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1622 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1623 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1624 |
"maxInclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) |
814 | 1625 |
}, |
1626 |
"reduce": GenerateFacetReducing("maxInclusive", True) |
|
1627 |
}, |
|
1628 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1629 |
"maxLength": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1630 |
"struct": """ |
814 | 1631 |
<maxLength |
1632 |
fixed = boolean : false |
|
1633 |
id = ID |
|
1634 |
value = nonNegativeInteger |
|
1635 |
{any attributes with non-schema namespace . . .}> |
|
1636 |
Content: (annotation?) |
|
1637 |
</maxLength>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1638 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1639 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1640 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1641 |
"maxLength", ["fixed", "id", "value"], ONLY_ANNOTATION) |
814 | 1642 |
}, |
1643 |
"reduce": GenerateFacetReducing("maxLength", True) |
|
1644 |
}, |
|
1645 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1646 |
"minExclusive": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1647 |
"struct": """ |
814 | 1648 |
<minExclusive |
1649 |
fixed = boolean : false |
|
1650 |
id = ID |
|
1651 |
value = anySimpleType |
|
1652 |
{any attributes with non-schema namespace . . .}> |
|
1653 |
Content: (annotation?) |
|
1654 |
</minExclusive>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1655 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1656 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1657 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1658 |
"minExclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) |
814 | 1659 |
}, |
1660 |
"reduce": GenerateFacetReducing("minExclusive", True) |
|
1661 |
}, |
|
1662 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1663 |
"minInclusive": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1664 |
"struct": """ |
814 | 1665 |
<minInclusive |
1666 |
fixed = boolean : false |
|
1667 |
id = ID |
|
1668 |
value = anySimpleType |
|
1669 |
{any attributes with non-schema namespace . . .}> |
|
1670 |
Content: (annotation?) |
|
1671 |
</minInclusive>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1672 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1673 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1674 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1675 |
"minInclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) |
814 | 1676 |
}, |
1677 |
"reduce": GenerateFacetReducing("minInclusive", True) |
|
1678 |
}, |
|
1679 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1680 |
"minLength": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1681 |
"struct": """ |
814 | 1682 |
<minLength |
1683 |
fixed = boolean : false |
|
1684 |
id = ID |
|
1685 |
value = nonNegativeInteger |
|
1686 |
{any attributes with non-schema namespace . . .}> |
|
1687 |
Content: (annotation?) |
|
1688 |
</minLength>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1689 |
"type": SYNTAXELEMENT, |
814 | 1690 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1691 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1692 |
"minLength", ["fixed", "id", "value"], ONLY_ANNOTATION) |
814 | 1693 |
}, |
1694 |
"reduce": GenerateFacetReducing("minLength", True) |
|
1695 |
}, |
|
1696 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1697 |
"pattern": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1698 |
"struct": """ |
814 | 1699 |
<pattern |
1700 |
id = ID |
|
1701 |
value = string |
|
1702 |
{any attributes with non-schema namespace . . .}> |
|
1703 |
Content: (annotation?) |
|
1704 |
</pattern>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1705 |
"type": SYNTAXELEMENT, |
814 | 1706 |
"extract": { |
1707 |
"default": GenerateElement("pattern", ["id", "value"], ONLY_ANNOTATION) |
|
1708 |
}, |
|
1709 |
"reduce": GenerateFacetReducing("pattern", False) |
|
1710 |
}, |
|
1711 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1712 |
"redefine": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1713 |
"struct": """ |
814 | 1714 |
<redefine |
1715 |
id = ID |
|
1716 |
schemaLocation = anyURI |
|
1717 |
{any attributes with non-schema namespace . . .}> |
|
1718 |
Content: (annotation | (simpleType | complexType | group | attributeGroup))* |
|
1719 |
</redefine>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1720 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1721 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1722 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1723 |
"refine", ["id", "schemaLocation"], |
814 | 1724 |
re.compile("((?:annotation |(?:simpleType |complexType |group |attributeGroup ))*)")) |
1725 |
}, |
|
1726 |
"reduce": ReduceRedefine |
|
1727 |
}, |
|
1728 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1729 |
"restriction": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1730 |
"struct": """ |
814 | 1731 |
<restriction |
1732 |
base = QName |
|
1733 |
id = ID |
|
1734 |
{any attributes with non-schema namespace . . .}> |
|
1735 |
Content: (annotation?, (group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)) |
|
1736 |
</restriction>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1737 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1738 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1739 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1740 |
"restriction", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1741 |
["base", "id"], |
814 | 1742 |
re.compile("((?:annotation )?(?:(?:simpleType )?(?:(?:minExclusive |minInclusive |maxExclusive |maxInclusive |totalDigits |fractionDigits |length |minLength |maxLength |enumeration |whiteSpace |pattern )*)))")), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1743 |
"simpleContent": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1744 |
"restriction", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1745 |
["base", "id"], |
814 | 1746 |
re.compile("((?:annotation )?(?:(?:simpleType )?(?:(?:minExclusive |minInclusive |maxExclusive |maxInclusive |totalDigits |fractionDigits |length |minLength |maxLength |enumeration |whiteSpace |pattern )*)?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?)))")), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1747 |
"complexContent": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1748 |
"restriction", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1749 |
["base", "id"], |
814 | 1750 |
re.compile("((?:annotation )?(?:(?:simpleType )?(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?)))")), |
1751 |
}, |
|
1752 |
"reduce": ReduceRestriction |
|
1753 |
}, |
|
1754 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1755 |
"schema": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1756 |
"struct": """ |
814 | 1757 |
<schema |
1758 |
attributeFormDefault = (qualified | unqualified) : unqualified |
|
1759 |
blockDefault = (#all | List of (extension | restriction | substitution)) : '' |
|
1760 |
elementFormDefault = (qualified | unqualified) : unqualified |
|
1761 |
finalDefault = (#all | List of (extension | restriction | list | union)) : '' |
|
1762 |
id = ID |
|
1763 |
targetNamespace = anyURI |
|
1764 |
version = token |
|
1765 |
xml:lang = language |
|
1766 |
{any attributes with non-schema namespace . . .}> |
|
1767 |
Content: ((include | import | redefine | annotation)*, (((simpleType | complexType | group | attributeGroup) | element | attribute | notation), annotation*)*) |
|
1768 |
</schema>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1769 |
"type": SYNTAXELEMENT, |
814 | 1770 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1771 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1772 |
"schema", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1773 |
["attributeFormDefault", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1774 |
"blockDefault", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1775 |
"elementFormDefault", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1776 |
"finalDefault", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1777 |
"id", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1778 |
"targetNamespace", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1779 |
"version", |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1780 |
"lang"], |
814 | 1781 |
re.compile("((?:include |import |redefine |annotation )*(?:(?:(?:simpleType |complexType |group |attributeGroup )|element |attribute |annotation )(?:annotation )*)*)")) |
1782 |
} |
|
1783 |
}, |
|
1784 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1785 |
"selector": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1786 |
"struct": """ |
814 | 1787 |
<selector |
1788 |
id = ID |
|
1789 |
xpath = a subset of XPath expression, see below |
|
1790 |
{any attributes with non-schema namespace . . .}> |
|
1791 |
Content: (annotation?) |
|
1792 |
</selector>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1793 |
"type": SYNTAXELEMENT, |
814 | 1794 |
"extract": { |
1795 |
"default": GenerateElement("selector", ["id", "xpath"], ONLY_ANNOTATION) |
|
1796 |
}, |
|
1797 |
"reduce": ReduceSelector |
|
1798 |
}, |
|
1799 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1800 |
"sequence": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1801 |
"struct": """ |
814 | 1802 |
<sequence |
1803 |
id = ID |
|
1804 |
maxOccurs = (nonNegativeInteger | unbounded) : 1 |
|
1805 |
minOccurs = nonNegativeInteger : 1 |
|
1806 |
{any attributes with non-schema namespace . . .}> |
|
1807 |
Content: (annotation?, (element | group | choice | sequence | any)*) |
|
1808 |
</sequence>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1809 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1810 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1811 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1812 |
"sequence", ["id", "maxOccurs", "minOccurs"], |
814 | 1813 |
re.compile("((?:annotation )?(?:element |group |choice |sequence |any )*)")) |
1814 |
}, |
|
1815 |
"reduce": ReduceSequence |
|
1816 |
}, |
|
1817 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1818 |
"simpleContent": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1819 |
"struct": """ |
814 | 1820 |
<simpleContent |
1821 |
id = ID |
|
1822 |
{any attributes with non-schema namespace . . .}> |
|
1823 |
Content: (annotation?, (restriction | extension)) |
|
1824 |
</simpleContent>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1825 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1826 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1827 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1828 |
"simpleContent", ["id"], |
814 | 1829 |
re.compile("((?:annotation )?(?:restriction |extension ))")) |
1830 |
}, |
|
1831 |
"reduce": ReduceSimpleContent |
|
1832 |
}, |
|
1833 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1834 |
"simpleType": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1835 |
"struct": """ |
814 | 1836 |
<simpleType |
1837 |
final = (#all | List of (list | union | restriction)) |
|
1838 |
id = ID |
|
1839 |
name = NCName |
|
1840 |
{any attributes with non-schema namespace . . .}> |
|
1841 |
Content: (annotation?, (restriction | list | union)) |
|
1842 |
</simpleType>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1843 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1844 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1845 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1846 |
"simpleType", ["final", "id", "name"], |
814 | 1847 |
re.compile("((?:annotation )?(?:restriction |list |union ))")) |
1848 |
}, |
|
1849 |
"reduce": ReduceSimpleType |
|
1850 |
}, |
|
1851 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1852 |
"totalDigits": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1853 |
"struct": """ |
814 | 1854 |
<totalDigits |
1855 |
fixed = boolean : false |
|
1856 |
id = ID |
|
1857 |
value = positiveInteger |
|
1858 |
{any attributes with non-schema namespace . . .}> |
|
1859 |
Content: (annotation?) |
|
1860 |
</totalDigits>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1861 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1862 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1863 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1864 |
"totalDigits", ["fixed", "id", "value"], ONLY_ANNOTATION), |
814 | 1865 |
}, |
1866 |
"reduce": GenerateFacetReducing("totalDigits", True) |
|
1867 |
}, |
|
1868 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1869 |
"union": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1870 |
"struct": """ |
814 | 1871 |
<union |
1872 |
id = ID |
|
1873 |
memberTypes = List of QName |
|
1874 |
{any attributes with non-schema namespace . . .}> |
|
1875 |
Content: (annotation?, simpleType*) |
|
1876 |
</union>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1877 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1878 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1879 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1880 |
"union", ["id", "memberTypes"], |
814 | 1881 |
re.compile("((?:annotation )?(?:simpleType )*)")) |
1882 |
}, |
|
1883 |
"reduce": ReduceUnion |
|
1884 |
}, |
|
1885 |
||
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1886 |
"unique": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1887 |
"struct": """ |
814 | 1888 |
<unique |
1889 |
id = ID |
|
1890 |
name = NCName |
|
1891 |
{any attributes with non-schema namespace . . .}> |
|
1892 |
Content: (annotation?, (selector, field+)) |
|
1893 |
</unique>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1894 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1895 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1896 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1897 |
"unique", ["id", "name"], |
814 | 1898 |
re.compile("((?:annotation )?(?:selector |(?:field )+))")) |
1899 |
}, |
|
1900 |
"reduce": ReduceUnique |
|
1901 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1902 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1903 |
"whiteSpace": { |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1904 |
"struct": """ |
814 | 1905 |
<whiteSpace |
1906 |
fixed = boolean : false |
|
1907 |
id = ID |
|
1908 |
value = (collapse | preserve | replace) |
|
1909 |
{any attributes with non-schema namespace . . .}> |
|
1910 |
Content: (annotation?) |
|
1911 |
</whiteSpace>""", |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1912 |
"type": SYNTAXELEMENT, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1913 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1914 |
"default": GenerateElement( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1915 |
"whiteSpace", ["fixed", "id", "value"], ONLY_ANNOTATION) |
814 | 1916 |
}, |
1917 |
"reduce": GenerateFacetReducing("whiteSpace", True) |
|
1918 |
}, |
|
1919 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
1920 |
# ------------------------------------------------------------------------------- |
1776
81aa8aaccdd4
clean-up: fix PEP8 E122 continuation line missing indentation or outdented
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1921 |
# Syntax attributes definition |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
1922 |
# ------------------------------------------------------------------------------- |
814 | 1923 |
|
1924 |
"abstract": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1925 |
"type": SYNTAXATTRIBUTE, |
814 | 1926 |
"extract": { |
1927 |
"default": GetBoolean |
|
1928 |
}, |
|
1929 |
"default": { |
|
1930 |
"default": False |
|
1931 |
} |
|
1932 |
}, |
|
1933 |
||
1934 |
"attributeFormDefault": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1935 |
"type": SYNTAXATTRIBUTE, |
814 | 1936 |
"extract": { |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1937 |
"default": GenerateEnumeratedExtraction( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
1938 |
"member attributeFormDefault", ["qualified", "unqualified"]) |
814 | 1939 |
}, |
1940 |
"default": { |
|
1941 |
"default": "unqualified" |
|
1942 |
} |
|
1943 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1944 |
|
814 | 1945 |
"base": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1946 |
"type": SYNTAXATTRIBUTE, |
814 | 1947 |
"extract": { |
1948 |
"default": GenerateModelNameExtraction("member base", QName_model) |
|
1949 |
} |
|
1950 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1951 |
|
814 | 1952 |
"block": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1953 |
"type": SYNTAXATTRIBUTE, |
814 | 1954 |
"extract": { |
1955 |
"default": GenerateGetList("block", ["restriction", "extension", "substitution"]) |
|
1956 |
} |
|
1957 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1958 |
|
814 | 1959 |
"blockDefault": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1960 |
"type": SYNTAXATTRIBUTE, |
814 | 1961 |
"extract": { |
1962 |
"default": GenerateGetList("block", ["restriction", "extension", "substitution"]) |
|
1963 |
}, |
|
1964 |
"default": { |
|
1965 |
"default": "" |
|
1966 |
} |
|
1967 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1968 |
|
814 | 1969 |
"default": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1970 |
"type": SYNTAXATTRIBUTE, |
814 | 1971 |
"extract": { |
1972 |
"default": GetAttributeValue |
|
1973 |
} |
|
1974 |
}, |
|
1975 |
||
1976 |
"elementFormDefault": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1977 |
"type": SYNTAXATTRIBUTE, |
814 | 1978 |
"extract": { |
1979 |
"default": GenerateEnumeratedExtraction("member elementFormDefault", ["qualified", "unqualified"]) |
|
1980 |
}, |
|
1981 |
"default": { |
|
1982 |
"default": "unqualified" |
|
1983 |
} |
|
1984 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1985 |
|
814 | 1986 |
"final": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1987 |
"type": SYNTAXATTRIBUTE, |
814 | 1988 |
"extract": { |
1989 |
"default": GenerateGetList("final", ["restriction", "extension", "substitution"]), |
|
1990 |
"simpleType": GenerateGetList("final", ["list", "union", "restriction"]) |
|
1991 |
} |
|
1992 |
}, |
|
1993 |
||
1994 |
"finalDefault": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1995 |
"type": SYNTAXATTRIBUTE, |
814 | 1996 |
"extract": { |
1997 |
"default": GenerateGetList("finalDefault", ["restriction", "extension", "list", "union"]) |
|
1998 |
}, |
|
1999 |
"default": { |
|
2000 |
"default": "" |
|
2001 |
} |
|
2002 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2003 |
|
814 | 2004 |
"fixed": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2005 |
"type": SYNTAXATTRIBUTE, |
814 | 2006 |
"extract": { |
2007 |
"default": GetBoolean, |
|
2008 |
"attribute": GetAttributeValue, |
|
2009 |
"element": GetAttributeValue |
|
2010 |
}, |
|
2011 |
"default": { |
|
2012 |
"default": False, |
|
2013 |
"attribute": None, |
|
2014 |
"element": None |
|
2015 |
} |
|
2016 |
}, |
|
2017 |
||
2018 |
"form": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2019 |
"type": SYNTAXATTRIBUTE, |
814 | 2020 |
"extract": { |
2021 |
"default": GenerateEnumeratedExtraction("member form", ["qualified", "unqualified"]) |
|
2022 |
} |
|
2023 |
}, |
|
2024 |
||
2025 |
"id": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2026 |
"type": SYNTAXATTRIBUTE, |
814 | 2027 |
"extract": { |
2028 |
"default": GenerateModelNameExtraction("member id", NCName_model) |
|
2029 |
} |
|
2030 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2031 |
|
814 | 2032 |
"itemType": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2033 |
"type": SYNTAXATTRIBUTE, |
814 | 2034 |
"extract": { |
2035 |
"default": GenerateModelNameExtraction("member itemType", QName_model) |
|
2036 |
} |
|
2037 |
}, |
|
2038 |
||
2039 |
"memberTypes": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2040 |
"type": SYNTAXATTRIBUTE, |
814 | 2041 |
"extract": { |
2042 |
"default": GenerateModelNameListExtraction("member memberTypes", QNames_model) |
|
2043 |
}, |
|
2044 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2045 |
|
814 | 2046 |
"maxOccurs": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2047 |
"type": SYNTAXATTRIBUTE, |
814 | 2048 |
"extract": { |
2049 |
"default": GenerateLimitExtraction(), |
|
2050 |
"all": GenerateLimitExtraction(1, 1, False) |
|
2051 |
}, |
|
2052 |
"default": { |
|
2053 |
"default": 1 |
|
2054 |
} |
|
2055 |
}, |
|
2056 |
||
2057 |
"minOccurs": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2058 |
"type": SYNTAXATTRIBUTE, |
814 | 2059 |
"extract": { |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
2060 |
"default": GenerateLimitExtraction(unbounded=False), |
814 | 2061 |
"all": GenerateLimitExtraction(0, 1, False) |
2062 |
}, |
|
2063 |
"default": { |
|
2064 |
"default": 1 |
|
2065 |
} |
|
2066 |
}, |
|
2067 |
||
2068 |
"mixed": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2069 |
"type": SYNTAXATTRIBUTE, |
814 | 2070 |
"extract": { |
2071 |
"default": GetBoolean |
|
2072 |
}, |
|
2073 |
"default": { |
|
2074 |
"default": None, |
|
2075 |
"complexType": False |
|
2076 |
} |
|
2077 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2078 |
|
814 | 2079 |
"name": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2080 |
"type": SYNTAXATTRIBUTE, |
814 | 2081 |
"extract": { |
2082 |
"default": GenerateModelNameExtraction("member name", NCName_model) |
|
2083 |
} |
|
2084 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2085 |
|
814 | 2086 |
"namespace": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2087 |
"type": SYNTAXATTRIBUTE, |
814 | 2088 |
"extract": { |
2089 |
"default": GenerateModelNameExtraction("member namespace", URI_model), |
|
2090 |
"any": GetNamespaces |
|
2091 |
}, |
|
2092 |
"default": { |
|
2093 |
"default": None, |
|
2094 |
"any": "##any" |
|
2095 |
} |
|
2096 |
}, |
|
2097 |
||
2098 |
"nillable": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2099 |
"type": SYNTAXATTRIBUTE, |
814 | 2100 |
"extract": { |
2101 |
"default": GetBoolean |
|
2102 |
}, |
|
2103 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2104 |
|
814 | 2105 |
"processContents": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2106 |
"type": SYNTAXATTRIBUTE, |
814 | 2107 |
"extract": { |
2108 |
"default": GenerateEnumeratedExtraction("member processContents", ["lax", "skip", "strict"]) |
|
2109 |
}, |
|
2110 |
"default": { |
|
2111 |
"default": "strict" |
|
2112 |
} |
|
2113 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2114 |
|
814 | 2115 |
"ref": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2116 |
"type": SYNTAXATTRIBUTE, |
814 | 2117 |
"extract": { |
2118 |
"default": GenerateModelNameExtraction("member ref", QName_model) |
|
2119 |
} |
|
2120 |
}, |
|
2121 |
||
2122 |
"refer": { |
|
2123 |
"type": SYNTAXATTRIBUTE, |
|
2124 |
"extract": { |
|
2125 |
"default": GenerateModelNameExtraction("member refer", QName_model) |
|
2126 |
} |
|
2127 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2128 |
|
814 | 2129 |
"schemaLocation": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2130 |
"type": SYNTAXATTRIBUTE, |
814 | 2131 |
"extract": { |
2132 |
"default": GenerateModelNameExtraction("member schemaLocation", URI_model) |
|
2133 |
} |
|
2134 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2135 |
|
814 | 2136 |
"source": { |
2137 |
"type": SYNTAXATTRIBUTE, |
|
2138 |
"extract": { |
|
2139 |
"default": GenerateModelNameExtraction("member source", URI_model) |
|
2140 |
} |
|
2141 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2142 |
|
814 | 2143 |
"substitutionGroup": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2144 |
"type": SYNTAXATTRIBUTE, |
814 | 2145 |
"extract": { |
2146 |
"default": GenerateModelNameExtraction("member substitutionGroup", QName_model) |
|
2147 |
} |
|
2148 |
}, |
|
2149 |
||
2150 |
"targetNamespace": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2151 |
"type": SYNTAXATTRIBUTE, |
814 | 2152 |
"extract": { |
2153 |
"default": GenerateModelNameExtraction("member targetNamespace", URI_model) |
|
2154 |
} |
|
2155 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2156 |
|
814 | 2157 |
"type": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2158 |
"type": SYNTAXATTRIBUTE, |
814 | 2159 |
"extract": { |
2160 |
"default": GenerateModelNameExtraction("member type", QName_model) |
|
2161 |
} |
|
2162 |
}, |
|
2163 |
||
2164 |
"use": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2165 |
"type": SYNTAXATTRIBUTE, |
814 | 2166 |
"extract": { |
2167 |
"default": GenerateEnumeratedExtraction("member usage", ["required", "optional", "prohibited"]) |
|
2168 |
}, |
|
2169 |
"default": { |
|
2170 |
"default": "optional" |
|
2171 |
} |
|
2172 |
}, |
|
2173 |
||
2174 |
"value": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2175 |
"type": SYNTAXATTRIBUTE, |
814 | 2176 |
"extract": { |
2177 |
"default": GetAttributeValue, |
|
2178 |
"fractionDigits": GenerateIntegerExtraction(minInclusive=0), |
|
2179 |
"length": GenerateIntegerExtraction(minInclusive=0), |
|
2180 |
"maxLength": GenerateIntegerExtraction(minInclusive=0), |
|
2181 |
"minLength": GenerateIntegerExtraction(minInclusive=0), |
|
2182 |
"totalDigits": GenerateIntegerExtraction(minExclusive=0), |
|
2183 |
"whiteSpace": GenerateEnumeratedExtraction("value", ["collapse", "preserve", "replace"]) |
|
2184 |
} |
|
2185 |
}, |
|
2186 |
||
2187 |
"version": { |
|
2188 |
"type": SYNTAXATTRIBUTE, |
|
2189 |
"extract": { |
|
2190 |
"default": GetToken |
|
2191 |
} |
|
2192 |
}, |
|
2193 |
||
2194 |
"xpath": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2195 |
"type": SYNTAXATTRIBUTE, |
814 | 2196 |
"extract": { |
1776
81aa8aaccdd4
clean-up: fix PEP8 E122 continuation line missing indentation or outdented
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
2197 |
# "default": NotSupportedYet("xpath") |
814 | 2198 |
"default": GetAttributeValue |
2199 |
} |
|
2200 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2201 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
2202 |
# ------------------------------------------------------------------------------- |
1776
81aa8aaccdd4
clean-up: fix PEP8 E122 continuation line missing indentation or outdented
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
2203 |
# Simple types definition |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
2204 |
# ------------------------------------------------------------------------------- |
814 | 2205 |
|
2206 |
"string": { |
|
2207 |
"type": SIMPLETYPE, |
|
2208 |
"basename": "string", |
|
2209 |
"extract": GetAttributeValue, |
|
2210 |
"facets": STRING_FACETS, |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
2211 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
814 | 2212 |
"initial": lambda: "", |
3752 | 2213 |
"check": lambda x: isinstance(x, str)}, |
814 | 2214 |
|
2215 |
"normalizedString": { |
|
2216 |
"type": SIMPLETYPE, |
|
2217 |
"basename": "normalizedString", |
|
2218 |
"extract": GetNormalizedString, |
|
2219 |
"facets": STRING_FACETS, |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
2220 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
814 | 2221 |
"initial": lambda: "", |
3752 | 2222 |
"check": lambda x: isinstance(x, str) |
814 | 2223 |
}, |
2224 |
||
2225 |
"token": { |
|
2226 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2227 |
"basename": "token", |
814 | 2228 |
"extract": GetToken, |
2229 |
"facets": STRING_FACETS, |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
2230 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
814 | 2231 |
"initial": lambda: "", |
3752 | 2232 |
"check": lambda x: isinstance(x, str) |
814 | 2233 |
}, |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2234 |
|
814 | 2235 |
"base64Binary": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2236 |
"type": SIMPLETYPE, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2237 |
"basename": "base64Binary", |
814 | 2238 |
"extract": NotSupportedYet("base64Binary"), |
2239 |
"facets": STRING_FACETS, |
|
2240 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2241 |
"initial": lambda: 0, |
|
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
2242 |
"check": lambda x: isinstance(x, int) |
814 | 2243 |
}, |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2244 |
|
814 | 2245 |
"hexBinary": { |
2246 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2247 |
"basename": "hexBinary", |
814 | 2248 |
"extract": GetHexInteger, |
2249 |
"facets": STRING_FACETS, |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
2250 |
"generate": GenerateSimpleTypeXMLText(lambda x: ("%."+str(int(round(len("%X" % x)/2.)*2))+"X") % x), |
814 | 2251 |
"initial": lambda: 0, |
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
2457
diff
changeset
|
2252 |
"check": lambda x: isinstance(x, int) |
814 | 2253 |
}, |
2254 |
||
2255 |
"integer": { |
|
2256 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2257 |
"basename": "integer", |
814 | 2258 |
"extract": GenerateIntegerExtraction(), |
2259 |
"facets": DECIMAL_FACETS, |
|
2260 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2261 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2262 |
"check": lambda x: isinstance(x, int) |
814 | 2263 |
}, |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2264 |
|
814 | 2265 |
"positiveInteger": { |
2266 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2267 |
"basename": "positiveInteger", |
814 | 2268 |
"extract": GenerateIntegerExtraction(minExclusive=0), |
2269 |
"facets": DECIMAL_FACETS, |
|
2270 |
"generate": GenerateSimpleTypeXMLText(str), |
|
1078
f0ea86d830ed
Fixed wrong default value for xsd:positiveInteger and xsd:negativeInteger in xmlclass
Laurent Bessard
parents:
814
diff
changeset
|
2271 |
"initial": lambda: 1, |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2272 |
"check": lambda x: isinstance(x, int) |
814 | 2273 |
}, |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2274 |
|
814 | 2275 |
"negativeInteger": { |
2276 |
"type": SIMPLETYPE, |
|
2277 |
"basename": "negativeInteger", |
|
2278 |
"extract": GenerateIntegerExtraction(maxExclusive=0), |
|
2279 |
"facets": DECIMAL_FACETS, |
|
2280 |
"generate": GenerateSimpleTypeXMLText(str), |
|
1078
f0ea86d830ed
Fixed wrong default value for xsd:positiveInteger and xsd:negativeInteger in xmlclass
Laurent Bessard
parents:
814
diff
changeset
|
2281 |
"initial": lambda: -1, |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2282 |
"check": lambda x: isinstance(x, int) |
814 | 2283 |
}, |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2284 |
|
814 | 2285 |
"nonNegativeInteger": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2286 |
"type": SIMPLETYPE, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2287 |
"basename": "nonNegativeInteger", |
814 | 2288 |
"extract": GenerateIntegerExtraction(minInclusive=0), |
2289 |
"facets": DECIMAL_FACETS, |
|
2290 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2291 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2292 |
"check": lambda x: isinstance(x, int) |
814 | 2293 |
}, |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2294 |
|
814 | 2295 |
"nonPositiveInteger": { |
2296 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2297 |
"basename": "nonPositiveInteger", |
814 | 2298 |
"extract": GenerateIntegerExtraction(maxInclusive=0), |
2299 |
"facets": DECIMAL_FACETS, |
|
2300 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2301 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2302 |
"check": lambda x: isinstance(x, int) |
814 | 2303 |
}, |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2304 |
|
814 | 2305 |
"long": { |
2306 |
"type": SIMPLETYPE, |
|
2307 |
"basename": "long", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2308 |
"extract": GenerateIntegerExtraction(minInclusive=-2**63, maxExclusive=2**63), |
814 | 2309 |
"facets": DECIMAL_FACETS, |
2310 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2311 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2312 |
"check": lambda x: isinstance(x, int) |
814 | 2313 |
}, |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2314 |
|
814 | 2315 |
"unsignedLong": { |
2316 |
"type": SIMPLETYPE, |
|
2317 |
"basename": "unsignedLong", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2318 |
"extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**64), |
814 | 2319 |
"facets": DECIMAL_FACETS, |
2320 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2321 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2322 |
"check": lambda x: isinstance(x, int) |
814 | 2323 |
}, |
2324 |
||
2325 |
"int": { |
|
2326 |
"type": SIMPLETYPE, |
|
2327 |
"basename": "int", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2328 |
"extract": GenerateIntegerExtraction(minInclusive=-2**31, maxExclusive=2**31), |
814 | 2329 |
"facets": DECIMAL_FACETS, |
2330 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2331 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2332 |
"check": lambda x: isinstance(x, int) |
814 | 2333 |
}, |
2334 |
||
2335 |
"unsignedInt": { |
|
2336 |
"type": SIMPLETYPE, |
|
2337 |
"basename": "unsignedInt", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2338 |
"extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**32), |
814 | 2339 |
"facets": DECIMAL_FACETS, |
2340 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2341 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2342 |
"check": lambda x: isinstance(x, int) |
814 | 2343 |
}, |
2344 |
||
2345 |
"short": { |
|
2346 |
"type": SIMPLETYPE, |
|
2347 |
"basename": "short", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2348 |
"extract": GenerateIntegerExtraction(minInclusive=-2**15, maxExclusive=2**15), |
814 | 2349 |
"facets": DECIMAL_FACETS, |
2350 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2351 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2352 |
"check": lambda x: isinstance(x, int) |
814 | 2353 |
}, |
2354 |
||
2355 |
"unsignedShort": { |
|
2356 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2357 |
"basename": "unsignedShort", |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2358 |
"extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**16), |
814 | 2359 |
"facets": DECIMAL_FACETS, |
2360 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2361 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2362 |
"check": lambda x: isinstance(x, int) |
814 | 2363 |
}, |
2364 |
||
2365 |
"byte": { |
|
2366 |
"type": SIMPLETYPE, |
|
2367 |
"basename": "byte", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2368 |
"extract": GenerateIntegerExtraction(minInclusive=-2**7, maxExclusive=2**7), |
814 | 2369 |
"facets": DECIMAL_FACETS, |
2370 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2371 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2372 |
"check": lambda x: isinstance(x, int) |
814 | 2373 |
}, |
2374 |
||
2375 |
"unsignedByte": { |
|
2376 |
"type": SIMPLETYPE, |
|
2377 |
"basename": "unsignedByte", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2378 |
"extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**8), |
814 | 2379 |
"facets": DECIMAL_FACETS, |
2380 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2381 |
"initial": lambda: 0, |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2382 |
"check": lambda x: isinstance(x, int) |
814 | 2383 |
}, |
2384 |
||
2385 |
"decimal": { |
|
2386 |
"type": SIMPLETYPE, |
|
2387 |
"basename": "decimal", |
|
2388 |
"extract": GenerateFloatExtraction("decimal"), |
|
2389 |
"facets": DECIMAL_FACETS, |
|
1373
4278d5c1e414
Fixed bug when graphic element position and size and connection points are decimal
Laurent Bessard
parents:
1322
diff
changeset
|
2390 |
"generate": GenerateFloatXMLText(decimal=3), |
814 | 2391 |
"initial": lambda: 0., |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2392 |
"check": lambda x: isinstance(x, (int, float)) |
814 | 2393 |
}, |
2394 |
||
2395 |
"float": { |
|
2396 |
"type": SIMPLETYPE, |
|
2397 |
"basename": "float", |
|
2398 |
"extract": GenerateFloatExtraction("float", ["INF", "-INF", "NaN"]), |
|
2399 |
"facets": NUMBER_FACETS, |
|
2400 |
"generate": GenerateFloatXMLText(["INF", "-INF", "NaN"]), |
|
2401 |
"initial": lambda: 0., |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2402 |
"check": lambda x: {"INF": True, "-INF": True, "NaN": True}.get(x, isinstance(x, (int, float))) |
814 | 2403 |
}, |
2404 |
||
2405 |
"double": { |
|
2406 |
"type": SIMPLETYPE, |
|
2407 |
"basename": "double", |
|
2408 |
"extract": GenerateFloatExtraction("double", ["INF", "-INF", "NaN"]), |
|
2409 |
"facets": NUMBER_FACETS, |
|
2410 |
"generate": GenerateFloatXMLText(["INF", "-INF", "NaN"]), |
|
2411 |
"initial": lambda: 0., |
|
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2412 |
"check": lambda x: {"INF": True, "-INF": True, "NaN": True}.get(x, isinstance(x, (int, float))) |
814 | 2413 |
}, |
2414 |
||
2415 |
"boolean": { |
|
2416 |
"type": SIMPLETYPE, |
|
2417 |
"basename": "boolean", |
|
2418 |
"extract": GetBoolean, |
|
2419 |
"facets": GenerateDictFacets(["pattern", "whiteSpace"]), |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2420 |
"generate": GenerateSimpleTypeXMLText(lambda x: {True: "true", False: "false"}[x]), |
814 | 2421 |
"initial": lambda: False, |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
2422 |
"check": lambda x: isinstance(x, bool) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2423 |
}, |
814 | 2424 |
|
2425 |
"duration": { |
|
2426 |
"type": SIMPLETYPE, |
|
2427 |
"basename": "duration", |
|
2428 |
"extract": NotSupportedYet("duration"), |
|
2429 |
"facets": NUMBER_FACETS, |
|
2430 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2431 |
"initial": lambda: "", |
|
3752 | 2432 |
"check": lambda x: isinstance(x, str) |
814 | 2433 |
}, |
2434 |
||
2435 |
"dateTime": { |
|
2436 |
"type": SIMPLETYPE, |
|
2437 |
"basename": "dateTime", |
|
2438 |
"extract": GetDateTime, |
|
2439 |
"facets": NUMBER_FACETS, |
|
2440 |
"generate": GenerateSimpleTypeXMLText(datetime.datetime.isoformat), |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2441 |
"initial": lambda: datetime.datetime(1, 1, 1, 0, 0, 0, 0), |
814 | 2442 |
"check": lambda x: isinstance(x, datetime.datetime) |
2443 |
}, |
|
2444 |
||
2445 |
"date": { |
|
2446 |
"type": SIMPLETYPE, |
|
2447 |
"basename": "date", |
|
2448 |
"extract": GetDate, |
|
2449 |
"facets": NUMBER_FACETS, |
|
2450 |
"generate": GenerateSimpleTypeXMLText(datetime.date.isoformat), |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2451 |
"initial": lambda: datetime.date(1, 1, 1), |
814 | 2452 |
"check": lambda x: isinstance(x, datetime.date) |
2453 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2454 |
|
814 | 2455 |
"time": { |
2456 |
"type": SIMPLETYPE, |
|
2457 |
"basename": "time", |
|
2458 |
"extract": GetTime, |
|
2459 |
"facets": NUMBER_FACETS, |
|
2460 |
"generate": GenerateSimpleTypeXMLText(datetime.time.isoformat), |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2461 |
"initial": lambda: datetime.time(0, 0, 0, 0), |
814 | 2462 |
"check": lambda x: isinstance(x, datetime.time) |
2463 |
}, |
|
2464 |
||
2465 |
"gYear": { |
|
2466 |
"type": SIMPLETYPE, |
|
2467 |
"basename": "gYear", |
|
2468 |
"extract": NotSupportedYet("gYear"), |
|
2469 |
"facets": NUMBER_FACETS, |
|
2470 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2471 |
"initial": lambda: "", |
|
3752 | 2472 |
"check": lambda x: isinstance(x, str) |
814 | 2473 |
}, |
2474 |
||
2475 |
"gYearMonth": { |
|
2476 |
"type": SIMPLETYPE, |
|
2477 |
"basename": "gYearMonth", |
|
2478 |
"extract": NotSupportedYet("gYearMonth"), |
|
2479 |
"facets": NUMBER_FACETS, |
|
2480 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2481 |
"initial": lambda: "", |
|
3752 | 2482 |
"check": lambda x: isinstance(x, str) |
814 | 2483 |
}, |
2484 |
||
2485 |
"gMonth": { |
|
2486 |
"type": SIMPLETYPE, |
|
2487 |
"basename": "gMonth", |
|
2488 |
"extract": NotSupportedYet("gMonth"), |
|
2489 |
"facets": NUMBER_FACETS, |
|
2490 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2491 |
"initial": lambda: "", |
|
3752 | 2492 |
"check": lambda x: isinstance(x, str) |
814 | 2493 |
}, |
2494 |
||
2495 |
"gMonthDay": { |
|
2496 |
"type": SIMPLETYPE, |
|
2497 |
"basename": "gMonthDay", |
|
2498 |
"extract": NotSupportedYet("gMonthDay"), |
|
2499 |
"facets": NUMBER_FACETS, |
|
2500 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2501 |
"initial": lambda: "", |
|
3752 | 2502 |
"check": lambda x: isinstance(x, str) |
814 | 2503 |
}, |
2504 |
||
2505 |
"gDay": { |
|
2506 |
"type": SIMPLETYPE, |
|
2507 |
"basename": "gDay", |
|
2508 |
"extract": NotSupportedYet("gDay"), |
|
2509 |
"facets": NUMBER_FACETS, |
|
2510 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2511 |
"initial": lambda: "", |
|
3752 | 2512 |
"check": lambda x: isinstance(x, str) |
814 | 2513 |
}, |
2514 |
||
2515 |
"Name": { |
|
2516 |
"type": SIMPLETYPE, |
|
2517 |
"basename": "Name", |
|
2518 |
"extract": GenerateModelNameExtraction("Name", Name_model), |
|
2519 |
"facets": STRING_FACETS, |
|
2520 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2521 |
"initial": lambda: "", |
|
3752 | 2522 |
"check": lambda x: isinstance(x, str) |
814 | 2523 |
}, |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2524 |
|
814 | 2525 |
"QName": { |
2526 |
"type": SIMPLETYPE, |
|
2527 |
"basename": "QName", |
|
2528 |
"extract": GenerateModelNameExtraction("QName", QName_model), |
|
2529 |
"facets": STRING_FACETS, |
|
2530 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2531 |
"initial": lambda: "", |
|
3752 | 2532 |
"check": lambda x: isinstance(x, str) |
814 | 2533 |
}, |
2534 |
||
2535 |
"NCName": { |
|
2536 |
"type": SIMPLETYPE, |
|
2537 |
"basename": "NCName", |
|
2538 |
"extract": GenerateModelNameExtraction("NCName", NCName_model), |
|
2539 |
"facets": STRING_FACETS, |
|
2540 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2541 |
"initial": lambda: "", |
|
3752 | 2542 |
"check": lambda x: isinstance(x, str) |
814 | 2543 |
}, |
2544 |
||
2545 |
"anyURI": { |
|
2546 |
"type": SIMPLETYPE, |
|
2547 |
"basename": "anyURI", |
|
2548 |
"extract": GenerateModelNameExtraction("anyURI", URI_model), |
|
2549 |
"facets": STRING_FACETS, |
|
2550 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2551 |
"initial": lambda: "", |
|
3752 | 2552 |
"check": lambda x: isinstance(x, str) |
814 | 2553 |
}, |
2554 |
||
2555 |
"language": { |
|
2556 |
"type": SIMPLETYPE, |
|
2557 |
"basename": "language", |
|
2558 |
"extract": GenerateModelNameExtraction("language", LANGUAGE_model), |
|
2559 |
"facets": STRING_FACETS, |
|
2560 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2561 |
"initial": lambda: "en", |
|
3752 | 2562 |
"check": lambda x: isinstance(x, str) |
814 | 2563 |
}, |
2564 |
||
2565 |
"ID": { |
|
2566 |
"type": SIMPLETYPE, |
|
2567 |
"basename": "ID", |
|
2568 |
"extract": GenerateModelNameExtraction("ID", Name_model), |
|
2569 |
"facets": STRING_FACETS, |
|
2570 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2571 |
"initial": lambda: "", |
|
3752 | 2572 |
"check": lambda x: isinstance(x, str) |
814 | 2573 |
}, |
2574 |
||
2575 |
"IDREF": { |
|
2576 |
"type": SIMPLETYPE, |
|
2577 |
"basename": "IDREF", |
|
2578 |
"extract": GenerateModelNameExtraction("IDREF", Name_model), |
|
2579 |
"facets": STRING_FACETS, |
|
2580 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2581 |
"initial": lambda: "", |
|
3752 | 2582 |
"check": lambda x: isinstance(x, str) |
814 | 2583 |
}, |
2584 |
||
2585 |
"IDREFS": { |
|
2586 |
"type": SIMPLETYPE, |
|
2587 |
"basename": "IDREFS", |
|
2588 |
"extract": GenerateModelNameExtraction("IDREFS", Names_model), |
|
2589 |
"facets": STRING_FACETS, |
|
2590 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2591 |
"initial": lambda: "", |
|
3752 | 2592 |
"check": lambda x: isinstance(x, str) |
814 | 2593 |
}, |
2594 |
||
2595 |
"ENTITY": { |
|
2596 |
"type": SIMPLETYPE, |
|
2597 |
"basename": "ENTITY", |
|
2598 |
"extract": GenerateModelNameExtraction("ENTITY", Name_model), |
|
2599 |
"facets": STRING_FACETS, |
|
2600 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2601 |
"initial": lambda: "", |
|
3752 | 2602 |
"check": lambda x: isinstance(x, str) |
814 | 2603 |
}, |
2604 |
||
2605 |
"ENTITIES": { |
|
2606 |
"type": SIMPLETYPE, |
|
2607 |
"basename": "ENTITIES", |
|
2608 |
"extract": GenerateModelNameExtraction("ENTITIES", Names_model), |
|
2609 |
"facets": STRING_FACETS, |
|
2610 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2611 |
"initial": lambda: "", |
|
3752 | 2612 |
"check": lambda x: isinstance(x, str) |
814 | 2613 |
}, |
2614 |
||
2615 |
"NOTATION": { |
|
2616 |
"type": SIMPLETYPE, |
|
2617 |
"basename": "NOTATION", |
|
2618 |
"extract": GenerateModelNameExtraction("NOTATION", Name_model), |
|
2619 |
"facets": STRING_FACETS, |
|
2620 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2621 |
"initial": lambda: "", |
|
3752 | 2622 |
"check": lambda x: isinstance(x, str) |
814 | 2623 |
}, |
2624 |
||
2625 |
"NMTOKEN": { |
|
2626 |
"type": SIMPLETYPE, |
|
2627 |
"basename": "NMTOKEN", |
|
2628 |
"extract": GenerateModelNameExtraction("NMTOKEN", NMToken_model), |
|
2629 |
"facets": STRING_FACETS, |
|
2630 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2631 |
"initial": lambda: "", |
|
3752 | 2632 |
"check": lambda x: isinstance(x, str) |
814 | 2633 |
}, |
2634 |
||
2635 |
"NMTOKENS": { |
|
2636 |
"type": SIMPLETYPE, |
|
2637 |
"basename": "NMTOKENS", |
|
2638 |
"extract": GenerateModelNameExtraction("NMTOKENS", NMTokens_model), |
|
2639 |
"facets": STRING_FACETS, |
|
2640 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2641 |
"initial": lambda: "", |
|
3752 | 2642 |
"check": lambda x: isinstance(x, str) |
814 | 2643 |
}, |
2644 |
||
2645 |
# Complex Types |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2646 |
"anyType": {"type": COMPLEXTYPE, "extract": lambda x: None}, |
814 | 2647 |
} |