author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Sat, 19 Aug 2017 00:30:22 +0300 | |
changeset 1772 | c3679f96020b |
parent 1768 | 691083b5682a |
child 1774 | ac0fe8aabb5e |
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 |
|
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
25 |
import os |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
26 |
import re |
814 | 27 |
import datetime |
28 |
from xml.dom import minidom |
|
29 |
from types import * |
|
30 |
||
31 |
from xmlclass import * |
|
32 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
33 |
|
814 | 34 |
def GenerateDictFacets(facets): |
35 |
return dict([(name, (None, False)) for name in facets]) |
|
36 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
37 |
|
814 | 38 |
def GenerateSimpleTypeXMLText(function): |
39 |
def generateXMLTextMethod(value, name=None, indent=0): |
|
40 |
text = "" |
|
41 |
if name is not None: |
|
42 |
ind1, ind2 = getIndent(indent, name) |
|
43 |
text += ind1 + "<%s>" % name |
|
44 |
text += function(value) |
|
45 |
if name is not None: |
|
46 |
text += "</%s>\n" % name |
|
47 |
return text |
|
48 |
return generateXMLTextMethod |
|
49 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
50 |
|
1373
4278d5c1e414
Fixed bug when graphic element position and size and connection points are decimal
Laurent Bessard
parents:
1322
diff
changeset
|
51 |
def GenerateFloatXMLText(extra_values=[], decimal=None): |
1374
1eefc427419f
Fixed bug with decimal value string formatting
Laurent Bessard
parents:
1373
diff
changeset
|
52 |
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
|
53 |
if decimal is not None else str) |
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
|
54 |
|
814 | 55 |
def generateXMLTextMethod(value, name=None, indent=0): |
56 |
text = "" |
|
57 |
if name is not None: |
|
58 |
ind1, ind2 = getIndent(indent, name) |
|
59 |
text += ind1 + "<%s>" % name |
|
1375
dc94c71a2f25
Fixed bug with decimal value string formatting
Laurent Bessard
parents:
1374
diff
changeset
|
60 |
if isinstance(value, IntType): |
dc94c71a2f25
Fixed bug with decimal value string formatting
Laurent Bessard
parents:
1374
diff
changeset
|
61 |
text += str(value) |
dc94c71a2f25
Fixed bug with decimal value string formatting
Laurent Bessard
parents:
1374
diff
changeset
|
62 |
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
|
63 |
text += float_format(value) |
814 | 64 |
else: |
1375
dc94c71a2f25
Fixed bug with decimal value string formatting
Laurent Bessard
parents:
1374
diff
changeset
|
65 |
text += "{:.0f}".format(value) |
814 | 66 |
if name is not None: |
67 |
text += "</%s>\n" % name |
|
68 |
return text |
|
69 |
return generateXMLTextMethod |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
70 |
|
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
|
71 |
|
814 | 72 |
DEFAULT_FACETS = GenerateDictFacets(["pattern", "whiteSpace", "enumeration"]) |
73 |
NUMBER_FACETS = GenerateDictFacets(DEFAULT_FACETS.keys() + ["maxInclusive", "maxExclusive", "minInclusive", "minExclusive"]) |
|
74 |
DECIMAL_FACETS = GenerateDictFacets(NUMBER_FACETS.keys() + ["totalDigits", "fractionDigits"]) |
|
75 |
STRING_FACETS = GenerateDictFacets(DEFAULT_FACETS.keys() + ["length", "minLength", "maxLength"]) |
|
76 |
||
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
77 |
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
|
78 |
"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
|
79 |
"fractionDigits", "length", "minLength", "maxLength"] |
814 | 80 |
|
81 |
||
82 |
#------------------------------------------------------------------------------- |
|
83 |
# Structure reducing functions |
|
84 |
#------------------------------------------------------------------------------- |
|
85 |
||
86 |
||
87 |
# Documentation elements |
|
88 |
||
89 |
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
|
90 |
return {"type": "appinfo", "source": attributes.get("source", None), |
814 | 91 |
"content": "\n".join(elements)} |
92 |
||
93 |
||
94 |
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
|
95 |
return {"type": "documentation", "source": attributes.get("source", None), |
814 | 96 |
"language": attributes.get("lang", "any"), "content": "\n".join(elements)} |
97 |
||
98 |
||
99 |
def ReduceAnnotation(factory, attributes, elements): |
|
100 |
annotations, children = factory.ReduceElements(elements) |
|
101 |
annotation = {"type": "annotation", "appinfo": [], "documentation": {}} |
|
102 |
for child in children: |
|
103 |
if child["type"] == "appinfo": |
|
104 |
annotation["appinfo"].append((child["source"], child["content"])) |
|
105 |
elif child["type"] == "documentation": |
|
106 |
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
|
107 |
text = "(source: %(source)s):\n%(content)s\n\n" % child |
814 | 108 |
else: |
109 |
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
|
110 |
if not child["language"] in annotation["documentation"]: |
814 | 111 |
annotation["documentation"] = text |
112 |
else: |
|
113 |
annotation["documentation"] += text |
|
114 |
return annotation |
|
115 |
||
116 |
# Simple type elements |
|
117 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
118 |
|
814 | 119 |
def GenerateFacetReducing(facetname, canbefixed): |
120 |
def ReduceFacet(factory, attributes, elements): |
|
121 |
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
|
122 |
if "value" in attributes: |
814 | 123 |
facet = {"type": facetname, "value": attributes["value"], "doc": annotations} |
124 |
if canbefixed: |
|
125 |
facet["fixed"] = attributes.get("fixed", False) |
|
126 |
return facet |
|
127 |
raise ValueError("A value must be defined for the \"%s\" facet!" % facetname) |
|
128 |
return ReduceFacet |
|
129 |
||
130 |
||
131 |
def ReduceList(factory, attributes, elements): |
|
132 |
annotations, children = factory.ReduceElements(elements) |
|
133 |
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
|
134 |
|
814 | 135 |
if len(children) > 0 and children[0]["type"] == SIMPLETYPE: |
136 |
if list["itemType"] is None: |
|
137 |
list["itemType"] = children[0] |
|
138 |
else: |
|
139 |
raise ValueError("Only one base type can be defined for restriction!") |
|
140 |
if list["itemType"] is None: |
|
141 |
raise ValueError("No base type has been defined for list!") |
|
142 |
return list |
|
143 |
||
144 |
||
145 |
def ReduceUnion(factory, attributes, elements): |
|
146 |
annotations, children = factory.ReduceElements(elements) |
|
147 |
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
|
148 |
|
814 | 149 |
for child in children: |
150 |
if child["type"] == SIMPLETYPE: |
|
151 |
union["memberTypes"].appendchild |
|
152 |
if len(union["memberTypes"]) == 0: |
|
153 |
raise ValueError("No base type has been defined for union!") |
|
154 |
return union |
|
155 |
||
156 |
||
157 |
def CreateSimpleType(factory, attributes, typeinfos): |
|
158 |
# Initialize type informations |
|
159 |
facets = {} |
|
160 |
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
|
161 |
if "name" in attributes: |
814 | 162 |
simpleType["name"] = attributes["name"] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
163 |
|
814 | 164 |
if typeinfos["type"] in ["restriction", "extension"]: |
165 |
# Search for base type definition |
|
166 |
if isinstance(typeinfos["base"], (StringType, UnicodeType)): |
|
167 |
basetypeinfos = factory.FindSchemaElement(typeinfos["base"], SIMPLETYPE) |
|
168 |
if basetypeinfos is None: |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
169 |
raise "\"%s\" isn't defined!" % typeinfos["base"] |
814 | 170 |
else: |
171 |
basetypeinfos = typeinfos["base"] |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
172 |
|
814 | 173 |
# Check that base type is a simple type |
174 |
if basetypeinfos["type"] != SIMPLETYPE: |
|
175 |
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
|
176 |
|
814 | 177 |
simpleType["basename"] = basetypeinfos["basename"] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
178 |
|
814 | 179 |
# 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
|
180 |
if "final" in basetypeinfos: |
814 | 181 |
if "#all" in basetypeinfos["final"]: |
182 |
raise ValueError("Base type can't be derivated!") |
|
183 |
if "restriction" in basetypeinfos["final"] and typeinfos["type"] == "restriction": |
|
184 |
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
|
185 |
|
814 | 186 |
# Extract simple type facets |
187 |
for facet in typeinfos.get("facets", []): |
|
188 |
facettype = 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
|
189 |
if not facettype in basetypeinfos["facets"]: |
814 | 190 |
raise ValueError("\"%s\" facet can't be defined for \"%s\" type!" % (facettype, type)) |
191 |
elif basetypeinfos["facets"][facettype][1]: |
|
192 |
raise ValueError("\"%s\" facet is fixed on base type!" % facettype) |
|
193 |
value = facet["value"] |
|
194 |
basevalue = basetypeinfos["facets"][facettype][0] |
|
195 |
if facettype in ["enumeration", "pattern"]: |
|
196 |
value = basetypeinfos["extract"](value, False) |
|
197 |
if len(facets) == 0: |
|
198 |
facets[facettype] = ([value], False) |
|
199 |
continue |
|
200 |
elif facets.keys() == [facettype]: |
|
201 |
facets[facettype][0].append(value) |
|
202 |
continue |
|
203 |
else: |
|
204 |
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
|
205 |
elif "enumeration" in facets: |
814 | 206 |
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
|
207 |
elif "pattern" in facets: |
814 | 208 |
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
|
209 |
elif facettype in facets: |
814 | 210 |
raise ValueError("\"%s\" facet can't be defined two times!" % facettype) |
211 |
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
|
212 |
if "minLength" in facets: |
814 | 213 |
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
|
214 |
if "maxLength" in facets: |
814 | 215 |
raise ValueError("\"length\" and \"maxLength\" facets can't be defined at the same time!") |
216 |
try: |
|
217 |
value = int(value) |
|
218 |
except: |
|
219 |
raise ValueError("\"length\" must be an integer!") |
|
220 |
if value < 0: |
|
221 |
raise ValueError("\"length\" can't be negative!") |
|
222 |
elif basevalue is not None and basevalue != value: |
|
223 |
raise ValueError("\"length\" can't be different from \"length\" defined in base type!") |
|
224 |
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
|
225 |
if "length" in facets: |
814 | 226 |
raise ValueError("\"length\" and \"minLength\" facets can't be defined at the same time!") |
227 |
try: |
|
228 |
value = int(value) |
|
229 |
except: |
|
230 |
raise ValueError("\"minLength\" must be an integer!") |
|
231 |
if value < 0: |
|
232 |
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
|
233 |
elif "maxLength" in facets and value > facets["maxLength"]: |
814 | 234 |
raise ValueError("\"minLength\" must be lesser than or equal to \"maxLength\"!") |
235 |
elif basevalue is not None and basevalue < value: |
|
236 |
raise ValueError("\"minLength\" can't be lesser than \"minLength\" defined in base type!") |
|
237 |
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
|
238 |
if "length" in facets: |
814 | 239 |
raise ValueError("\"length\" and \"maxLength\" facets can't be defined at the same time!") |
240 |
try: |
|
241 |
value = int(value) |
|
242 |
except: |
|
243 |
raise ValueError("\"maxLength\" must be an integer!") |
|
244 |
if value < 0: |
|
245 |
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
|
246 |
elif "minLength" in facets and value < facets["minLength"]: |
814 | 247 |
raise ValueError("\"minLength\" must be lesser than or equal to \"maxLength\"!") |
248 |
elif basevalue is not None and basevalue > value: |
|
249 |
raise ValueError("\"maxLength\" can't be greater than \"maxLength\" defined in base type!") |
|
250 |
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
|
251 |
if "minExclusive" in facets: |
814 | 252 |
raise ValueError("\"minExclusive\" and \"minInclusive\" facets can't be defined at the same time!") |
253 |
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
|
254 |
if "maxInclusive" in facets and value > facets["maxInclusive"][0]: |
814 | 255 |
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
|
256 |
elif "maxExclusive" in facets and value >= facets["maxExclusive"][0]: |
814 | 257 |
raise ValueError("\"minInclusive\" must be lesser than \"maxExclusive\"!") |
258 |
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
|
259 |
if "minInclusive" in facets: |
814 | 260 |
raise ValueError("\"minExclusive\" and \"minInclusive\" facets can't be defined at the same time!") |
261 |
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
|
262 |
if "maxInclusive" in facets and value >= facets["maxInclusive"][0]: |
814 | 263 |
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
|
264 |
elif "maxExclusive" in facets and value >= facets["maxExclusive"][0]: |
814 | 265 |
raise ValueError("\"minExclusive\" must be lesser than \"maxExclusive\"!") |
266 |
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
|
267 |
if "maxExclusive" in facets: |
814 | 268 |
raise ValueError("\"maxExclusive\" and \"maxInclusive\" facets can't be defined at the same time!") |
269 |
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
|
270 |
if "minInclusive" in facets and value < facets["minInclusive"][0]: |
814 | 271 |
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
|
272 |
elif "minExclusive" in facets and value <= facets["minExclusive"][0]: |
814 | 273 |
raise ValueError("\"minExclusive\" must be lesser than \"maxInclusive\"!") |
274 |
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
|
275 |
if "maxInclusive" in facets: |
814 | 276 |
raise ValueError("\"maxExclusive\" and \"maxInclusive\" facets can't be defined at the same time!") |
277 |
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
|
278 |
if "minInclusive" in facets and value <= facets["minInclusive"][0]: |
814 | 279 |
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
|
280 |
elif "minExclusive" in facets and value <= facets["minExclusive"][0]: |
814 | 281 |
raise ValueError("\"minExclusive\" must be lesser than \"maxExclusive\"!") |
282 |
elif facettype == "whiteSpace": |
|
283 |
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
|
284 |
raise ValueError("\"whiteSpace\" is incompatible with \"whiteSpace\" defined in base type!") |
814 | 285 |
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
|
286 |
if "fractionDigits" in facets and value <= facets["fractionDigits"][0]: |
814 | 287 |
raise ValueError("\"fractionDigits\" must be lesser than or equal to \"totalDigits\"!") |
288 |
elif basevalue is not None and value > basevalue: |
|
289 |
raise ValueError("\"totalDigits\" can't be greater than \"totalDigits\" defined in base type!") |
|
290 |
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
|
291 |
if "totalDigits" in facets and value <= facets["totalDigits"][0]: |
814 | 292 |
raise ValueError("\"fractionDigits\" must be lesser than or equal to \"totalDigits\"!") |
293 |
elif basevalue is not None and value > basevalue: |
|
294 |
raise ValueError("\"totalDigits\" can't be greater than \"totalDigits\" defined in base type!") |
|
295 |
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
|
296 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
297 |
# Report not redefined facet from base type to new created type |
814 | 298 |
for facettype, facetvalue in basetypeinfos["facets"].items(): |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
299 |
if not facettype in facets: |
814 | 300 |
facets[facettype] = facetvalue |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
301 |
|
814 | 302 |
# Generate extract value for new created type |
303 |
def ExtractSimpleTypeValue(attr, extract=True): |
|
304 |
value = basetypeinfos["extract"](attr, extract) |
|
305 |
for facetname, (facetvalue, facetfixed) in facets.items(): |
|
306 |
if facetvalue is not None: |
|
307 |
if facetname == "enumeration" and value not in facetvalue: |
|
308 |
raise ValueError("\"%s\" not in enumerated values" % value) |
|
309 |
elif facetname == "length" and len(value) != facetvalue: |
|
310 |
raise ValueError("value must have a length of %d" % facetvalue) |
|
311 |
elif facetname == "minLength" and len(value) < facetvalue: |
|
312 |
raise ValueError("value must have a length of %d at least" % facetvalue) |
|
313 |
elif facetname == "maxLength" and len(value) > facetvalue: |
|
314 |
raise ValueError("value must have a length of %d at most" % facetvalue) |
|
315 |
elif facetname == "minInclusive" and value < facetvalue: |
|
316 |
raise ValueError("value must be greater than or equal to %s" % str(facetvalue)) |
|
317 |
elif facetname == "minExclusive" and value <= facetvalue: |
|
318 |
raise ValueError("value must be greater than %s" % str(facetvalue)) |
|
319 |
elif facetname == "maxInclusive" and value > facetvalue: |
|
320 |
raise ValueError("value must be lesser than or equal to %s" % str(facetvalue)) |
|
321 |
elif facetname == "maxExclusive" and value >= facetvalue: |
|
322 |
raise ValueError("value must be lesser than %s" % str(facetvalue)) |
|
323 |
elif facetname == "pattern": |
|
324 |
model = re.compile("(?:%s)?$" % "|".join(map(lambda x: "(?:%s)" % x, facetvalue))) |
|
325 |
result = model.match(value) |
|
326 |
if result is None: |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
327 |
if len(facetvalue) > 1: |
814 | 328 |
raise ValueError("value doesn't follow any of the patterns %s" % ",".join(facetvalue)) |
329 |
else: |
|
330 |
raise ValueError("value doesn't follow the pattern %s" % facetvalue[0]) |
|
331 |
elif facetname == "whiteSpace": |
|
332 |
if facetvalue == "replace": |
|
333 |
value = GetNormalizedString(value, False) |
|
334 |
elif facetvalue == "collapse": |
|
335 |
value = GetToken(value, False) |
|
336 |
return value |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
337 |
|
814 | 338 |
def CheckSimpleTypeValue(value): |
339 |
for facetname, (facetvalue, facetfixed) in facets.items(): |
|
340 |
if facetvalue is not None: |
|
341 |
if facetname == "enumeration" and value not in facetvalue: |
|
342 |
return False |
|
343 |
elif facetname == "length" and len(value) != facetvalue: |
|
344 |
return False |
|
345 |
elif facetname == "minLength" and len(value) < facetvalue: |
|
346 |
return False |
|
347 |
elif facetname == "maxLength" and len(value) > facetvalue: |
|
348 |
return False |
|
349 |
elif facetname == "minInclusive" and value < facetvalue: |
|
350 |
return False |
|
351 |
elif facetname == "minExclusive" and value <= facetvalue: |
|
352 |
return False |
|
353 |
elif facetname == "maxInclusive" and value > facetvalue: |
|
354 |
return False |
|
355 |
elif facetname == "maxExclusive" and value >= facetvalue: |
|
356 |
return False |
|
357 |
elif facetname == "pattern": |
|
358 |
model = re.compile("(?:%s)?$" % "|".join(map(lambda x: "(?:%s)" % x, facetvalue))) |
|
359 |
result = model.match(value) |
|
360 |
if result is None: |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
361 |
if len(facetvalue) > 1: |
814 | 362 |
raise ValueError("value doesn't follow any of the patterns %s" % ",".join(facetvalue)) |
363 |
else: |
|
364 |
raise ValueError("value doesn't follow the pattern %s" % facetvalue[0]) |
|
365 |
return True |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
366 |
|
814 | 367 |
def SimpleTypeInitialValue(): |
368 |
for facetname, (facetvalue, facetfixed) in facets.items(): |
|
369 |
if facetvalue is not None: |
|
370 |
if facetname == "enumeration": |
|
371 |
return facetvalue[0] |
|
372 |
elif facetname == "length": |
|
373 |
return " "*facetvalue |
|
374 |
elif facetname == "minLength": |
|
375 |
return " "*minLength |
|
376 |
elif facetname == "minInclusive" and facetvalue > 0: |
|
377 |
return facetvalue |
|
378 |
elif facetname == "minExclusive" and facetvalue >= 0: |
|
379 |
return facetvalue + 1 |
|
380 |
elif facetname == "maxInclusive" and facetvalue < 0: |
|
381 |
return facetvalue |
|
382 |
elif facetname == "maxExclusive" and facetvalue <= 0: |
|
383 |
return facetvalue - 1 |
|
384 |
return basetypeinfos["initial"]() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
385 |
|
814 | 386 |
GenerateSimpleType = basetypeinfos["generate"] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
387 |
|
814 | 388 |
elif typeinfos["type"] == "list": |
389 |
# Search for item type definition |
|
390 |
if isinstance(typeinfos["itemType"], (StringType, UnicodeType)): |
|
391 |
itemtypeinfos = factory.FindSchemaElement(typeinfos["itemType"], SIMPLETYPE) |
|
392 |
if itemtypeinfos is None: |
|
393 |
raise "\"%s\" isn't defined!" % typeinfos["itemType"] |
|
394 |
else: |
|
395 |
itemtypeinfos = typeinfos["itemType"] |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
396 |
|
814 | 397 |
# Check that item type is a simple type |
398 |
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
|
399 |
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
|
400 |
|
814 | 401 |
simpleType["basename"] = "list" |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
402 |
|
814 | 403 |
# 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
|
404 |
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
|
405 |
if "#all" in itemtypeinfos["final"]: |
814 | 406 |
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
|
407 |
if "list" in itemtypeinfos["final"]: |
814 | 408 |
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
|
409 |
|
814 | 410 |
# 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
|
411 |
def ExtractSimpleTypeValue(attr, extract=True): |
814 | 412 |
values = [] |
413 |
for value in GetToken(attr, extract).split(" "): |
|
414 |
values.append(itemtypeinfos["extract"](value, False)) |
|
415 |
return values |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
416 |
|
814 | 417 |
def CheckSimpleTypeValue(value): |
418 |
for item in value: |
|
419 |
result = itemtypeinfos["check"](item) |
|
420 |
if not result: |
|
421 |
return result |
|
422 |
return True |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
423 |
|
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
|
424 |
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
|
425 |
return [] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
426 |
|
814 | 427 |
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
|
428 |
|
814 | 429 |
facets = GenerateDictFacets(["length", "maxLength", "minLength", "enumeration", "pattern"]) |
430 |
facets["whiteSpace"] = ("collapse", False) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
431 |
|
814 | 432 |
elif typeinfos["type"] == "union": |
433 |
# Search for member types definition |
|
434 |
membertypesinfos = [] |
|
435 |
for membertype in typeinfos["memberTypes"]: |
|
436 |
if isinstance(membertype, (StringType, UnicodeType)): |
|
437 |
infos = factory.FindSchemaElement(membertype, SIMPLETYPE) |
|
438 |
if infos is None: |
|
439 |
raise ValueError("\"%s\" isn't defined!" % membertype) |
|
440 |
else: |
|
441 |
infos = membertype |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
442 |
|
814 | 443 |
# Check that member type is a simple type |
444 |
if infos["type"] != SIMPLETYPE: |
|
445 |
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
|
446 |
|
814 | 447 |
# 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
|
448 |
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
|
449 |
if "#all" in infos["final"]: |
814 | 450 |
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
|
451 |
if "union" in infos["final"]: |
814 | 452 |
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
|
453 |
|
814 | 454 |
membertypesinfos.append(infos) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
455 |
|
814 | 456 |
simpleType["basename"] = "union" |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
457 |
|
814 | 458 |
# 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
|
459 |
def ExtractSimpleTypeValue(attr, extract=True): |
814 | 460 |
if extract: |
461 |
value = GetAttributeValue(attr) |
|
462 |
else: |
|
463 |
value = attr |
|
464 |
for infos in membertypesinfos: |
|
465 |
try: |
|
466 |
return infos["extract"](attr, False) |
|
467 |
except: |
|
468 |
pass |
|
469 |
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
|
470 |
|
814 | 471 |
def CheckSimpleTypeValue(value): |
472 |
for infos in membertypesinfos: |
|
473 |
result = infos["check"](value) |
|
474 |
if result: |
|
475 |
return result |
|
476 |
return False |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
477 |
|
814 | 478 |
SimpleTypeInitialValue = membertypesinfos[0]["initial"] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
479 |
|
814 | 480 |
def GenerateSimpleTypeFunction(value): |
481 |
if isinstance(value, BooleanType): |
|
482 |
return {True: "true", False: "false"}[value] |
|
483 |
else: |
|
484 |
return str(value) |
|
485 |
GenerateSimpleType = GenerateSimpleTypeXMLText(GenerateSimpleTypeFunction) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
486 |
|
814 | 487 |
facets = GenerateDictFacets(["pattern", "enumeration"]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
488 |
|
814 | 489 |
simpleType["facets"] = facets |
490 |
simpleType["extract"] = ExtractSimpleTypeValue |
|
491 |
simpleType["initial"] = SimpleTypeInitialValue |
|
492 |
simpleType["check"] = CheckSimpleTypeValue |
|
493 |
simpleType["generate"] = GenerateSimpleType |
|
494 |
return simpleType |
|
495 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
496 |
|
814 | 497 |
def ReduceSimpleType(factory, attributes, elements): |
498 |
# Reduce all the simple type children |
|
499 |
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
|
500 |
|
814 | 501 |
simpleType = CreateSimpleType(factory, attributes, children[0]) |
502 |
simpleType["doc"] = annotations |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
503 |
|
814 | 504 |
return simpleType |
505 |
||
506 |
# Complex type |
|
507 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
508 |
|
814 | 509 |
def ExtractAttributes(factory, elements, base=None): |
510 |
attrs = [] |
|
511 |
attrnames = {} |
|
512 |
if base is not None: |
|
513 |
basetypeinfos = factory.FindSchemaElement(base) |
|
514 |
if not isinstance(basetypeinfos, (UnicodeType, StringType)) and basetypeinfos["type"] == COMPLEXTYPE: |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
515 |
attrnames = dict(map(lambda x: (x["name"], True), basetypeinfos["attributes"])) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
516 |
|
814 | 517 |
for element in elements: |
518 |
if element["type"] == ATTRIBUTE: |
|
519 |
if attrnames.get(element["name"], False): |
|
520 |
raise ValueError("\"%s\" attribute has been defined two times!" % element["name"]) |
|
521 |
else: |
|
522 |
attrnames[element["name"]] = True |
|
523 |
attrs.append(element) |
|
524 |
elif element["type"] == "attributeGroup": |
|
525 |
attrgroup = factory.FindSchemaElement(element["ref"], ATTRIBUTESGROUP) |
|
526 |
for attr in attrgroup["attributes"]: |
|
527 |
if attrnames.get(attr["name"], False): |
|
528 |
raise ValueError("\"%s\" attribute has been defined two times!" % attr["name"]) |
|
529 |
else: |
|
530 |
attrnames[attr["name"]] = True |
|
531 |
attrs.append(attr) |
|
532 |
elif element["type"] == "anyAttribute": |
|
533 |
raise ValueError("\"anyAttribute\" element isn't supported yet!") |
|
534 |
return attrs |
|
535 |
||
536 |
||
537 |
def ReduceRestriction(factory, attributes, elements): |
|
538 |
annotations, children = factory.ReduceElements(elements) |
|
539 |
restriction = {"type": "restriction", "base": attributes.get("base", None), "facets": [], "doc": annotations} |
|
540 |
if len(children) > 0 and children[0]["type"] == SIMPLETYPE: |
|
541 |
if restriction["base"] is None: |
|
542 |
restriction["base"] = children.pop(0) |
|
543 |
else: |
|
544 |
raise ValueError("Only one base type can be defined for restriction!") |
|
545 |
if restriction["base"] is None: |
|
546 |
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
|
547 |
|
814 | 548 |
while len(children) > 0 and children[0]["type"] in ALL_FACETS: |
549 |
restriction["facets"].append(children.pop(0)) |
|
550 |
restriction["attributes"] = ExtractAttributes(factory, children, restriction["base"]) |
|
551 |
return restriction |
|
552 |
||
553 |
||
554 |
def ReduceExtension(factory, attributes, elements): |
|
555 |
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
|
556 |
if not "base" in attributes: |
814 | 557 |
raise ValueError("No base type has been defined for extension!") |
558 |
extension = {"type": "extension", "attributes": [], "elements": [], "base": attributes["base"], "doc": annotations} |
|
559 |
if len(children) > 0: |
|
560 |
if children[0]["type"] in ["group", "all", CHOICE, "sequence"]: |
|
561 |
group = children.pop(0) |
|
562 |
if group["type"] in ["all", "sequence"]: |
|
563 |
extension["elements"] = group["elements"] |
|
564 |
extension["order"] = group["order"] |
|
565 |
elif group["type"] == CHOICE: |
|
566 |
content = group.copy() |
|
567 |
content["name"] = "content" |
|
568 |
extension["elements"].append(content) |
|
569 |
elif group["type"] == "group": |
|
570 |
elmtgroup = factory.FindSchemaElement(child["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
|
571 |
if "elements" in elmtgroup: |
814 | 572 |
extension["elements"] = elmtgroup["elements"] |
573 |
extension["order"] = elmtgroup["order"] |
|
574 |
else: |
|
575 |
content = elmtgroup.copy() |
|
576 |
content["name"] = "content" |
|
577 |
extension["elements"].append(content) |
|
578 |
extension["attributes"] = ExtractAttributes(factory, children) |
|
579 |
return extension |
|
580 |
||
581 |
||
582 |
def ReduceSimpleContent(factory, attributes, elements): |
|
583 |
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
|
584 |
|
814 | 585 |
simpleContent = children[0].copy() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
586 |
|
814 | 587 |
basetypeinfos = factory.FindSchemaElement(simpleContent["base"]) |
588 |
if basetypeinfos["type"] == SIMPLETYPE: |
|
589 |
contenttypeinfos = simpleContent.copy() |
|
590 |
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
|
591 |
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
|
592 |
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
|
593 |
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
|
594 |
"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
|
595 |
basetypeinfos["elements"][0]["elmt_type"]["type"] == SIMPLETYPE): |
814 | 596 |
contenttypeinfos = simpleContent.copy() |
597 |
contenttypeinfos["base"] = basetypeinfos["elements"][0]["elmt_type"] |
|
598 |
else: |
|
599 |
raise ValueError("No compatible base type defined for simpleContent!") |
|
600 |
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
|
601 |
|
814 | 602 |
simpleContent["elements"] = [{"name": "content", "type": ELEMENT, |
603 |
"elmt_type": contenttypeinfos, "doc": annotations, |
|
604 |
"minOccurs": 1, "maxOccurs": 1}] |
|
605 |
simpleContent["type"] = "simpleContent" |
|
606 |
return simpleContent |
|
607 |
||
608 |
||
609 |
def ReduceComplexContent(factory, attributes, elements): |
|
610 |
annotations, children = factory.ReduceElements(elements) |
|
611 |
complexContent = children[0].copy() |
|
612 |
complexContent["type"] = "complexContent" |
|
613 |
return complexContent |
|
614 |
||
615 |
||
616 |
def ReduceComplexType(factory, attributes, elements): |
|
617 |
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
|
618 |
|
814 | 619 |
if len(children) > 0: |
620 |
if children[0]["type"] in ["simpleContent", "complexContent"]: |
|
621 |
complexType = children[0].copy() |
|
622 |
complexType.update(attributes) |
|
623 |
complexType["type"] = COMPLEXTYPE |
|
624 |
return complexType |
|
625 |
elif children[0]["type"] in ["group", "all", CHOICE, "sequence"]: |
|
626 |
complexType = {"type": COMPLEXTYPE, "elements": [], "order": True, "doc": annotations} |
|
627 |
complexType.update(attributes) |
|
628 |
group = children.pop(0) |
|
629 |
if group["type"] in ["all", "sequence"]: |
|
630 |
choice_number = 0 |
|
631 |
for element in group["elements"]: |
|
632 |
if element["type"] == CHOICE: |
|
633 |
choice_number += 1 |
|
634 |
if (group["minOccurs"] == 0 or group["maxOccurs"] != 1) and len(group["elements"]) > 1 or choice_number > 1: |
|
635 |
content = {"type": CHOICE, "name": "content", "choices": [group], "minOccurs": 1, "maxOccurs": 1} |
|
636 |
complexType["elements"].append(content) |
|
637 |
else: |
|
638 |
if len(group["elements"]) == 1: |
|
639 |
if group["minOccurs"] == 0: |
|
640 |
group["elements"][0]["minOccurs"] = group["minOccurs"] |
|
641 |
if group["maxOccurs"] != 1: |
|
642 |
group["elements"][0]["maxOccurs"] = group["maxOccurs"] |
|
643 |
for element in group["elements"]: |
|
644 |
if element["type"] == CHOICE: |
|
645 |
element["name"] = "content" |
|
646 |
complexType["elements"] = group["elements"] |
|
647 |
complexType["order"] = group["order"] |
|
648 |
elif group["type"] == CHOICE: |
|
649 |
content = group.copy() |
|
650 |
content["name"] = "content" |
|
651 |
complexType["elements"].append(content) |
|
652 |
elif group["type"] == "group": |
|
653 |
elmtgroup = factory.FindSchemaElement(child["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
|
654 |
if "elements" in elmtgroup: |
814 | 655 |
complexType["elements"] = elmtgroup["elements"] |
656 |
complexType["order"] = elmtgroup["order"] |
|
657 |
else: |
|
658 |
content = elmtgroup.copy() |
|
659 |
content["name"] = "content" |
|
660 |
complexType["elements"].append(content) |
|
661 |
else: |
|
662 |
complexType = {"elements": [], "order": True, "doc": annotations} |
|
663 |
complexType.update(attributes) |
|
664 |
complexType["type"] = COMPLEXTYPE |
|
665 |
complexType["attributes"] = ExtractAttributes(factory, children) |
|
666 |
return complexType |
|
667 |
else: |
|
668 |
raise ValueError("\"ComplexType\" can't be empty!") |
|
669 |
||
670 |
||
671 |
# Attribute elements |
|
672 |
||
673 |
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
|
674 |
return {"type": "anyAttribute"} |
814 | 675 |
|
676 |
||
677 |
def ReduceAttribute(factory, attributes, elements): |
|
678 |
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
|
679 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
680 |
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
|
681 |
if "fixed" in attributes: |
814 | 682 |
raise ValueError("\"default\" and \"fixed\" can't be defined at the same time!") |
683 |
elif attributes.get("use", "optional") != "optional": |
|
684 |
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
|
685 |
|
814 | 686 |
attribute = {"type": ATTRIBUTE, "attr_type": attributes.get("type", None), "doc": annotations} |
687 |
if len(children) > 0: |
|
688 |
if attribute["attr_type"] is None: |
|
689 |
attribute["attr_type"] = children[0] |
|
690 |
else: |
|
691 |
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
|
692 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
693 |
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
|
694 |
if "name" in attributes: |
814 | 695 |
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
|
696 |
elif "form" in attributes: |
814 | 697 |
raise ValueError("\"ref\" and \"form\" can't be defined at the same time!") |
698 |
elif attribute["attr_type"] is not None: |
|
699 |
raise ValueError("if \"ref\" is present, no type can be defined!") |
|
700 |
elif attribute["attr_type"] is None: |
|
701 |
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
|
702 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
703 |
if "type" in attributes: |
814 | 704 |
tmp_attrs = attributes.copy() |
705 |
tmp_attrs.pop("type") |
|
706 |
attribute.update(tmp_attrs) |
|
707 |
else: |
|
708 |
attribute.update(attributes) |
|
709 |
return attribute |
|
710 |
||
711 |
||
712 |
def ReduceAttributeGroup(factory, attributes, elements): |
|
713 |
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
|
714 |
if "ref" in attributes: |
814 | 715 |
return {"type": "attributeGroup", "ref": attributes["ref"], "doc": annotations} |
716 |
else: |
|
717 |
return {"type": ATTRIBUTESGROUP, "attributes": ExtractAttributes(factory, children), "doc": annotations} |
|
718 |
||
719 |
||
720 |
# Elements groups |
|
721 |
||
722 |
def ReduceAny(factory, attributes, elements): |
|
723 |
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
|
724 |
|
814 | 725 |
any = {"type": ANY, "doc": annotations} |
726 |
any.update(attributes) |
|
727 |
return any |
|
728 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
729 |
|
814 | 730 |
def ReduceElement(factory, attributes, elements): |
731 |
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
|
732 |
|
814 | 733 |
types = [] |
734 |
constraints = [] |
|
735 |
for child in children: |
|
736 |
if child["type"] == CONSTRAINT: |
|
737 |
constraints.append(child) |
|
738 |
else: |
|
739 |
types.append(child) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
740 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
741 |
if "default" in attributes and "fixed" in attributes: |
814 | 742 |
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
|
743 |
|
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 "ref" in attributes: |
814 | 745 |
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
|
746 |
if attr in attributes: |
814 | 747 |
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
|
748 |
if "nillable" in attributes: |
814 | 749 |
raise ValueError("\"ref\" and \"nillable\" can't be defined at the same time!") |
750 |
if len(types) > 0: |
|
751 |
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
|
752 |
|
814 | 753 |
infos = factory.FindSchemaElement(attributes["ref"], ELEMENT) |
754 |
if infos is not None: |
|
755 |
element = infos.copy() |
|
756 |
element["constraints"] = constraints |
|
757 |
element["minOccurs"] = attributes["minOccurs"] |
|
758 |
element["maxOccurs"] = attributes["maxOccurs"] |
|
759 |
return element |
|
760 |
else: |
|
761 |
raise ValueError("\"%s\" base type isn't defined or circular referenced!" % name) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
762 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
763 |
elif "name" in attributes: |
814 | 764 |
element = {"type": ELEMENT, "elmt_type": attributes.get("type", None), "constraints": constraints, "doc": annotations} |
765 |
if len(types) > 0: |
|
766 |
if element["elmt_type"] is None: |
|
767 |
element["elmt_type"] = types[0] |
|
768 |
else: |
|
769 |
raise ValueError("Only one type can be defined for attribute!") |
|
770 |
elif element["elmt_type"] is None: |
|
771 |
element["elmt_type"] = "tag" |
|
772 |
element["type"] = TAG |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
773 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
774 |
if "type" in attributes: |
814 | 775 |
tmp_attrs = attributes.copy() |
776 |
tmp_attrs.pop("type") |
|
777 |
element.update(tmp_attrs) |
|
778 |
else: |
|
779 |
element.update(attributes) |
|
780 |
return element |
|
781 |
else: |
|
782 |
raise ValueError("\"Element\" must have at least a \"ref\" or a \"name\" defined!") |
|
783 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
784 |
|
814 | 785 |
def ReduceAll(factory, attributes, elements): |
786 |
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
|
787 |
|
814 | 788 |
for child in children: |
789 |
if children["maxOccurs"] == "unbounded" or children["maxOccurs"] > 1: |
|
790 |
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
|
791 |
|
814 | 792 |
return {"type": "all", "elements": children, "minOccurs": attributes["minOccurs"], |
793 |
"maxOccurs": attributes["maxOccurs"], "order": False, "doc": annotations} |
|
794 |
||
795 |
||
796 |
def ReduceChoice(factory, attributes, elements): |
|
797 |
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
|
798 |
|
814 | 799 |
choices = [] |
800 |
for child in children: |
|
801 |
if child["type"] in [ELEMENT, ANY, TAG]: |
|
802 |
choices.append(child) |
|
803 |
elif child["type"] == "sequence": |
|
804 |
child["minOccurs"] = child["maxOccurs"] = 1 |
|
805 |
choices.append(child) |
|
806 |
#raise ValueError("\"sequence\" in \"choice\" is not supported. Create instead a new complex type!") |
|
807 |
elif child["type"] == CHOICE: |
|
808 |
choices.extend(child["choices"]) |
|
809 |
elif child["type"] == "group": |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
810 |
elmtgroup = factory.FindSchemaElement(child["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
|
811 |
if not "choices" in elmtgroup: |
814 | 812 |
raise ValueError("Only group composed of \"choice\" can be referenced in \"choice\" element!") |
813 |
choices_tmp = [] |
|
814 |
for choice in elmtgroup["choices"]: |
|
815 |
if not isinstance(choice["elmt_type"], (UnicodeType, StringType)) and choice["elmt_type"]["type"] == COMPLEXTYPE: |
|
816 |
elmt_type = "%s_%s" % (elmtgroup["name"], choice["name"]) |
|
817 |
if factory.TargetNamespace is not None: |
|
818 |
elmt_type = "%s:%s" % (factory.TargetNamespace, elmt_type) |
|
819 |
new_choice = choice.copy() |
|
820 |
new_choice["elmt_type"] = elmt_type |
|
821 |
choices_tmp.append(new_choice) |
|
822 |
else: |
|
823 |
choices_tmp.append(choice) |
|
824 |
choices.extend(choices_tmp) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
825 |
|
814 | 826 |
for choice in choices: |
827 |
attributes["minOccurs"] = min(attributes["minOccurs"], choice["minOccurs"]) |
|
828 |
choice["minOccurs"] = 1 |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
829 |
|
814 | 830 |
return {"type": CHOICE, "choices": choices, "minOccurs": attributes["minOccurs"], |
831 |
"maxOccurs": attributes["maxOccurs"], "doc": annotations} |
|
832 |
||
833 |
||
834 |
def ReduceSequence(factory, attributes, elements): |
|
835 |
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
|
836 |
|
814 | 837 |
sequence = [] |
838 |
for child in children: |
|
839 |
if child["type"] in [ELEMENT, ANY, TAG, CHOICE]: |
|
840 |
sequence.append(child) |
|
841 |
elif child["type"] == "sequence": |
|
842 |
sequence.extend(child["elements"]) |
|
843 |
elif child["type"] == "group": |
|
844 |
elmtgroup = factory.FindSchemaElement(child["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
|
845 |
if not "elements" in elmtgroup or not elmtgroup["order"]: |
814 | 846 |
raise ValueError("Only group composed of \"sequence\" can be referenced in \"sequence\" element!") |
847 |
elements_tmp = [] |
|
848 |
for element in elmtgroup["elements"]: |
|
849 |
if not isinstance(element["elmt_type"], (UnicodeType, StringType)) 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
|
850 |
elmt_type = "%s_%s" % (elmtgroup["name"], element["name"]) |
814 | 851 |
if factory.TargetNamespace is not None: |
852 |
elmt_type = "%s:%s" % (factory.TargetNamespace, elmt_type) |
|
853 |
new_element = element.copy() |
|
854 |
new_element["elmt_type"] = elmt_type |
|
855 |
elements_tmp.append(new_element) |
|
856 |
else: |
|
857 |
elements_tmp.append(element) |
|
858 |
sequence.extend(elements_tmp) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
859 |
|
814 | 860 |
return {"type": "sequence", "elements": sequence, "minOccurs": attributes["minOccurs"], |
861 |
"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
|
862 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
863 |
|
814 | 864 |
def ReduceGroup(factory, attributes, elements): |
865 |
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
|
866 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
867 |
if "ref" in attributes: |
814 | 868 |
return {"type": "group", "ref": attributes["ref"], "doc": annotations} |
869 |
else: |
|
870 |
element = children[0] |
|
871 |
group = {"type": ELEMENTSGROUP, "doc": annotations} |
|
872 |
if element["type"] == CHOICE: |
|
873 |
group["choices"] = element["choices"] |
|
874 |
else: |
|
1683
57b4ac796dcb
fix reducing groups with ordered elements
Surkov Sergey <surkovsv93@gmail.com>
parents:
1571
diff
changeset
|
875 |
group.update({"elements": element["elements"], "order": element["order"]}) |
814 | 876 |
group.update(attributes) |
877 |
return group |
|
878 |
||
879 |
# Constraint elements |
|
880 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
881 |
|
814 | 882 |
def ReduceUnique(factory, attributes, elements): |
883 |
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
|
884 |
|
814 | 885 |
unique = {"type": CONSTRAINT, "const_type": "unique", "selector": children[0], "fields": children[1:]} |
886 |
unique.update(attributes) |
|
887 |
return unique |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
888 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
889 |
|
814 | 890 |
def ReduceKey(factory, attributes, elements): |
891 |
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
|
892 |
|
814 | 893 |
key = {"type": CONSTRAINT, "const_type": "key", "selector": children[0], "fields": children[1:]} |
894 |
key.update(attributes) |
|
895 |
return key |
|
896 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
897 |
|
814 | 898 |
def ReduceKeyRef(factory, attributes, elements): |
899 |
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
|
900 |
|
814 | 901 |
keyref = {"type": CONSTRAINT, "const_type": "keyref", "selector": children[0], "fields": children[1:]} |
902 |
keyref.update(attributes) |
|
903 |
return keyref |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
904 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
905 |
|
814 | 906 |
def ReduceSelector(factory, attributes, elements): |
907 |
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
|
908 |
|
814 | 909 |
selector = {"type": CONSTRAINT, "const_type": "selector"} |
910 |
selector.update(attributes) |
|
911 |
return selector |
|
912 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
913 |
|
814 | 914 |
def ReduceField(factory, attributes, elements): |
915 |
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
|
916 |
|
814 | 917 |
field = {"type": CONSTRAINT, "const_type": "field"} |
918 |
field.update(attributes) |
|
919 |
return field |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
920 |
|
814 | 921 |
|
922 |
# Inclusion elements |
|
923 |
||
924 |
def ReduceImport(factory, attributes, elements): |
|
925 |
annotations, children = factory.ReduceElements(elements) |
|
926 |
raise ValueError("\"import\" element isn't supported yet!") |
|
927 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
928 |
|
814 | 929 |
def ReduceInclude(factory, attributes, elements): |
930 |
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
|
931 |
|
814 | 932 |
if factory.FileName is None: |
933 |
raise ValueError("Include in XSD string not yet supported") |
|
934 |
filepath = attributes["schemaLocation"] |
|
935 |
if filepath is not None and not os.path.exists(filepath): |
|
936 |
filepath = os.path.join(factory.BaseFolder, filepath) |
|
937 |
if not os.path.exists(filepath): |
|
938 |
raise ValueError("No file '%s' found for include" % attributes["schemaLocation"]) |
|
939 |
xsdfile = open(filepath, 'r') |
|
940 |
include_factory = XSDClassFactory(minidom.parse(xsdfile), filepath) |
|
941 |
xsdfile.close() |
|
942 |
include_factory.CreateClasses() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
943 |
|
814 | 944 |
if factory.TargetNamespace == include_factory.TargetNamespace: |
945 |
factory.Namespaces[factory.TargetNamespace].update(include_factory.Namespaces[include_factory.TargetNamespace]) |
|
946 |
else: |
|
947 |
factory.Namespaces[include_factory.TargetNamespace] = include_factory.Namespaces[include_factory.TargetNamespace] |
|
948 |
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
|
949 |
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
|
950 |
factory.EquivalentClassesParent.update(include_factory.EquivalentClassesParent) |
814 | 951 |
return None |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
952 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
953 |
|
814 | 954 |
def ReduceRedefine(factory, attributes, elements): |
955 |
annotations, children = factory.ReduceElements(elements) |
|
956 |
raise ValueError("\"redefine\" element isn't supported yet!") |
|
957 |
||
958 |
||
959 |
# Schema element |
|
960 |
||
961 |
def ReduceSchema(factory, attributes, elements): |
|
962 |
factory.AttributeFormDefault = attributes["attributeFormDefault"] |
|
963 |
factory.ElementFormDefault = attributes["elementFormDefault"] |
|
964 |
factory.BlockDefault = attributes["blockDefault"] |
|
965 |
factory.FinalDefault = attributes["finalDefault"] |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
966 |
|
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1290
diff
changeset
|
967 |
targetNamespace = attributes.get("targetNamespace", None) |
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1290
diff
changeset
|
968 |
factory.TargetNamespace = factory.DefinedNamespaces.get(targetNamespace, None) |
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
969 |
if factory.TargetNamespace is not None: |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1290
diff
changeset
|
970 |
factory.etreeNamespaceFormat = "{%s}%%s" % targetNamespace |
814 | 971 |
factory.Namespaces[factory.TargetNamespace] = {} |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
972 |
|
814 | 973 |
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
|
974 |
|
814 | 975 |
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
|
976 |
if "name" in child: |
814 | 977 |
infos = factory.GetQualifiedNameInfos(child["name"], factory.TargetNamespace, True) |
978 |
if infos is None: |
|
979 |
factory.Namespaces[factory.TargetNamespace][child["name"]] = child |
|
980 |
elif not CompareSchema(infos, child): |
|
981 |
raise ValueError("\"%s\" is defined twice in targetNamespace!" % child["name"]) |
|
982 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
983 |
|
814 | 984 |
def CompareSchema(schema, reference): |
985 |
if isinstance(schema, ListType): |
|
986 |
if not isinstance(reference, ListType) or len(schema) != len(reference): |
|
987 |
return False |
|
988 |
for i, value in enumerate(schema): |
|
989 |
result = CompareSchema(value, reference[i]) |
|
990 |
if not result: |
|
991 |
return result |
|
992 |
return True |
|
993 |
elif isinstance(schema, DictType): |
|
994 |
if not isinstance(reference, DictType) or len(schema) != len(reference): |
|
995 |
return False |
|
996 |
for name, value in schema.items(): |
|
997 |
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
|
998 |
if ref_value is None and value is not None: |
814 | 999 |
return False |
1000 |
result = CompareSchema(value, ref_value) |
|
1001 |
if not result: |
|
1002 |
return result |
|
1003 |
return True |
|
1004 |
elif isinstance(schema, FunctionType): |
|
1005 |
if not isinstance(reference, FunctionType) or schema.__name__ != reference.__name__: |
|
1006 |
return False |
|
1007 |
else: |
|
1008 |
return True |
|
1009 |
return schema == reference |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1010 |
|
814 | 1011 |
#------------------------------------------------------------------------------- |
1012 |
# Base class for XSD schema extraction |
|
1013 |
#------------------------------------------------------------------------------- |
|
1014 |
||
1015 |
||
1016 |
class XSDClassFactory(ClassFactory): |
|
1017 |
||
1018 |
def __init__(self, document, filepath=None, debug=False): |
|
1019 |
ClassFactory.__init__(self, document, filepath, debug) |
|
1020 |
self.Namespaces["xml"] = { |
|
1021 |
"lang": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1022 |
"type": SYNTAXATTRIBUTE, |
814 | 1023 |
"extract": { |
1024 |
"default": GenerateModelNameExtraction("lang", LANGUAGE_model) |
|
1025 |
} |
|
1026 |
} |
|
1027 |
} |
|
1028 |
self.Namespaces["xsi"] = { |
|
1029 |
"noNamespaceSchemaLocation": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1030 |
"type": SYNTAXATTRIBUTE, |
814 | 1031 |
"extract": { |
1032 |
"default": NotSupportedYet("noNamespaceSchemaLocation") |
|
1033 |
} |
|
1034 |
}, |
|
1035 |
"nil": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1036 |
"type": SYNTAXATTRIBUTE, |
814 | 1037 |
"extract": { |
1038 |
"default": NotSupportedYet("nil") |
|
1039 |
} |
|
1040 |
}, |
|
1041 |
"schemaLocation": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1042 |
"type": SYNTAXATTRIBUTE, |
814 | 1043 |
"extract": { |
1044 |
"default": NotSupportedYet("schemaLocation") |
|
1045 |
} |
|
1046 |
}, |
|
1047 |
"type": { |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1048 |
"type": SYNTAXATTRIBUTE, |
814 | 1049 |
"extract": { |
1050 |
"default": NotSupportedYet("type") |
|
1051 |
} |
|
1052 |
} |
|
1053 |
} |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1054 |
|
814 | 1055 |
def ParseSchema(self): |
1056 |
for child in self.Document.childNodes: |
|
1057 |
if child.nodeType == self.Document.ELEMENT_NODE: |
|
1058 |
schema = child |
|
1059 |
break |
|
1060 |
for qualified_name, attr in schema._attrs.items(): |
|
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1061 |
namespace, name = DecomposeQualifiedName(qualified_name) |
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1062 |
if namespace == "xmlns": |
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1063 |
value = GetAttributeValue(attr) |
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1064 |
self.DefinedNamespaces[value] = name |
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1065 |
self.NSMAP[name] = value |
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1066 |
if value == "http://www.w3.org/2001/XMLSchema": |
814 | 1067 |
self.SchemaNamespace = name |
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1068 |
self.Namespaces[self.SchemaNamespace] = XSD_NAMESPACE |
814 | 1069 |
self.Schema = XSD_NAMESPACE["schema"]["extract"]["default"](self, schema) |
1070 |
ReduceSchema(self, self.Schema[1], self.Schema[2]) |
|
1071 |
||
1072 |
def FindSchemaElement(self, element_name, element_type=None): |
|
1073 |
namespace, name = DecomposeQualifiedName(element_name) |
|
1074 |
element = self.GetQualifiedNameInfos(name, namespace, True) |
|
1075 |
if element is None and namespace == self.TargetNamespace and name not in self.CurrentCompilations: |
|
1076 |
self.CurrentCompilations.append(name) |
|
1077 |
element = self.CreateSchemaElement(name, element_type) |
|
1078 |
self.CurrentCompilations.pop(-1) |
|
1079 |
if element is not None: |
|
1080 |
self.Namespaces[self.TargetNamespace][name] = element |
|
1081 |
if element is None: |
|
1082 |
if name in self.CurrentCompilations: |
|
1083 |
if self.Debug: |
|
1084 |
print "Warning : \"%s\" is circular referenced!" % element_name |
|
1085 |
else: |
|
1086 |
raise ValueError("\"%s\" isn't defined!" % element_name) |
|
1087 |
if element_type is not None and element["type"] != element_type: |
|
1088 |
raise ValueError("\"%s\" isn't of the expected type!" % element_name) |
|
1089 |
return element |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
1090 |
|
814 | 1091 |
def CreateSchemaElement(self, element_name, element_type): |
1092 |
for type, attributes, elements in self.Schema[2]: |
|
1093 |
namespace, name = DecomposeQualifiedName(type) |
|
1094 |
if attributes.get("name", None) == element_name: |
|
1095 |
element_infos = None |
|
1096 |
if element_type in (ATTRIBUTE, None) and name == "attribute": |
|
1097 |
element_infos = ReduceAttribute(self, attributes, elements) |
|
1098 |
elif element_type in (ELEMENT, None) and name == "element": |
|
1099 |
element_infos = ReduceElement(self, attributes, elements) |
|
1100 |
elif element_type in (ATTRIBUTESGROUP, None) and name == "attributeGroup": |
|
1101 |
element_infos = ReduceAttributeGroup(self, attributes, elements) |
|
1102 |
elif element_type in (ELEMENTSGROUP, None) and name == "group": |
|
1103 |
element_infos = ReduceGroup(self, attributes, elements) |
|
1104 |
elif element_type in (SIMPLETYPE, None) and name == "simpleType": |
|
1105 |
element_infos = ReduceSimpleType(self, attributes, elements) |
|
1106 |
elif element_type in (COMPLEXTYPE, None) and name == "complexType": |
|
1107 |
element_infos = ReduceComplexType(self, attributes, elements) |
|
1108 |
if element_infos is not None: |
|
1109 |
self.Namespaces[self.TargetNamespace][element_name] = element_infos |
|
1110 |
return element_infos |
|
1111 |
return None |
|
1112 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1113 |
|
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1114 |
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
|
1115 |
""" |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1116 |
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
|
1117 |
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
|
1118 |
""" |
814 | 1119 |
xsdfile = open(filepath, 'r') |
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1120 |
xsdstring = xsdfile.read() |
814 | 1121 |
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
|
1122 |
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
|
1123 |
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
|
1124 |
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
|
1125 |
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
|
1126 |
return parser |
814 | 1127 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1128 |
|
1290
13ee5f4ab612
First stage of xmlclass refactoring using lxml
Laurent Bessard
parents:
1078
diff
changeset
|
1129 |
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
|
1130 |
""" |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
1131 |
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
|
1132 |
""" |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1290
diff
changeset
|
1133 |
return GenerateParser(XSDClassFactory(minidom.parseString(xsdstring)), xsdstring) |
814 | 1134 |
|
1135 |
||
1136 |
#------------------------------------------------------------------------------- |
|
1137 |
# XSD schema syntax elements |
|
1138 |
#------------------------------------------------------------------------------- |
|
1139 |
||
1140 |
XSD_NAMESPACE = { |
|
1141 |
||
1142 |
#------------------------------------------------------------------------------- |
|
1143 |
# Syntax elements definition |
|
1144 |
#------------------------------------------------------------------------------- |
|
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 |
||
1920 |
#------------------------------------------------------------------------------- |
|
1921 |
# Syntax attributes definition |
|
1922 |
#------------------------------------------------------------------------------- |
|
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": { |
2197 |
# "default": NotSupportedYet("xpath") |
|
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 |
|
814 | 2202 |
#------------------------------------------------------------------------------- |
2203 |
# Simple types definition |
|
2204 |
#------------------------------------------------------------------------------- |
|
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: "", |
2213 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2214 |
}, |
|
2215 |
||
2216 |
"normalizedString": { |
|
2217 |
"type": SIMPLETYPE, |
|
2218 |
"basename": "normalizedString", |
|
2219 |
"extract": GetNormalizedString, |
|
2220 |
"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
|
2221 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
814 | 2222 |
"initial": lambda: "", |
2223 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2224 |
}, |
|
2225 |
||
2226 |
"token": { |
|
2227 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2228 |
"basename": "token", |
814 | 2229 |
"extract": GetToken, |
2230 |
"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
|
2231 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
814 | 2232 |
"initial": lambda: "", |
2233 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2234 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2235 |
|
814 | 2236 |
"base64Binary": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2237 |
"type": SIMPLETYPE, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2238 |
"basename": "base64Binary", |
814 | 2239 |
"extract": NotSupportedYet("base64Binary"), |
2240 |
"facets": STRING_FACETS, |
|
2241 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2242 |
"initial": lambda: 0, |
|
2243 |
"check": lambda x: isinstance(x, (IntType, LongType)) |
|
2244 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2245 |
|
814 | 2246 |
"hexBinary": { |
2247 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2248 |
"basename": "hexBinary", |
814 | 2249 |
"extract": GetHexInteger, |
2250 |
"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
|
2251 |
"generate": GenerateSimpleTypeXMLText(lambda x: ("%."+str(int(round(len("%X" % x)/2.)*2))+"X") % x), |
814 | 2252 |
"initial": lambda: 0, |
2253 |
"check": lambda x: isinstance(x, (IntType, LongType)) |
|
2254 |
}, |
|
2255 |
||
2256 |
"integer": { |
|
2257 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2258 |
"basename": "integer", |
814 | 2259 |
"extract": GenerateIntegerExtraction(), |
2260 |
"facets": DECIMAL_FACETS, |
|
2261 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2262 |
"initial": lambda: 0, |
|
2263 |
"check": lambda x: isinstance(x, IntType) |
|
2264 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2265 |
|
814 | 2266 |
"positiveInteger": { |
2267 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2268 |
"basename": "positiveInteger", |
814 | 2269 |
"extract": GenerateIntegerExtraction(minExclusive=0), |
2270 |
"facets": DECIMAL_FACETS, |
|
2271 |
"generate": GenerateSimpleTypeXMLText(str), |
|
1078
f0ea86d830ed
Fixed wrong default value for xsd:positiveInteger and xsd:negativeInteger in xmlclass
Laurent Bessard
parents:
814
diff
changeset
|
2272 |
"initial": lambda: 1, |
814 | 2273 |
"check": lambda x: isinstance(x, IntType) |
2274 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2275 |
|
814 | 2276 |
"negativeInteger": { |
2277 |
"type": SIMPLETYPE, |
|
2278 |
"basename": "negativeInteger", |
|
2279 |
"extract": GenerateIntegerExtraction(maxExclusive=0), |
|
2280 |
"facets": DECIMAL_FACETS, |
|
2281 |
"generate": GenerateSimpleTypeXMLText(str), |
|
1078
f0ea86d830ed
Fixed wrong default value for xsd:positiveInteger and xsd:negativeInteger in xmlclass
Laurent Bessard
parents:
814
diff
changeset
|
2282 |
"initial": lambda: -1, |
814 | 2283 |
"check": lambda x: isinstance(x, IntType) |
2284 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2285 |
|
814 | 2286 |
"nonNegativeInteger": { |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2287 |
"type": SIMPLETYPE, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2288 |
"basename": "nonNegativeInteger", |
814 | 2289 |
"extract": GenerateIntegerExtraction(minInclusive=0), |
2290 |
"facets": DECIMAL_FACETS, |
|
2291 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2292 |
"initial": lambda: 0, |
|
2293 |
"check": lambda x: isinstance(x, IntType) |
|
2294 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2295 |
|
814 | 2296 |
"nonPositiveInteger": { |
2297 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2298 |
"basename": "nonPositiveInteger", |
814 | 2299 |
"extract": GenerateIntegerExtraction(maxInclusive=0), |
2300 |
"facets": DECIMAL_FACETS, |
|
2301 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2302 |
"initial": lambda: 0, |
|
2303 |
"check": lambda x: isinstance(x, IntType) |
|
2304 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2305 |
|
814 | 2306 |
"long": { |
2307 |
"type": SIMPLETYPE, |
|
2308 |
"basename": "long", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2309 |
"extract": GenerateIntegerExtraction(minInclusive=-2**63, maxExclusive=2**63), |
814 | 2310 |
"facets": DECIMAL_FACETS, |
2311 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2312 |
"initial": lambda: 0, |
|
2313 |
"check": lambda x: isinstance(x, IntType) |
|
2314 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2315 |
|
814 | 2316 |
"unsignedLong": { |
2317 |
"type": SIMPLETYPE, |
|
2318 |
"basename": "unsignedLong", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2319 |
"extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**64), |
814 | 2320 |
"facets": DECIMAL_FACETS, |
2321 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2322 |
"initial": lambda: 0, |
|
2323 |
"check": lambda x: isinstance(x, IntType) |
|
2324 |
}, |
|
2325 |
||
2326 |
"int": { |
|
2327 |
"type": SIMPLETYPE, |
|
2328 |
"basename": "int", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2329 |
"extract": GenerateIntegerExtraction(minInclusive=-2**31, maxExclusive=2**31), |
814 | 2330 |
"facets": DECIMAL_FACETS, |
2331 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2332 |
"initial": lambda: 0, |
|
2333 |
"check": lambda x: isinstance(x, IntType) |
|
2334 |
}, |
|
2335 |
||
2336 |
"unsignedInt": { |
|
2337 |
"type": SIMPLETYPE, |
|
2338 |
"basename": "unsignedInt", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2339 |
"extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**32), |
814 | 2340 |
"facets": DECIMAL_FACETS, |
2341 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2342 |
"initial": lambda: 0, |
|
2343 |
"check": lambda x: isinstance(x, IntType) |
|
2344 |
}, |
|
2345 |
||
2346 |
"short": { |
|
2347 |
"type": SIMPLETYPE, |
|
2348 |
"basename": "short", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2349 |
"extract": GenerateIntegerExtraction(minInclusive=-2**15, maxExclusive=2**15), |
814 | 2350 |
"facets": DECIMAL_FACETS, |
2351 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2352 |
"initial": lambda: 0, |
|
2353 |
"check": lambda x: isinstance(x, IntType) |
|
2354 |
}, |
|
2355 |
||
2356 |
"unsignedShort": { |
|
2357 |
"type": SIMPLETYPE, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2358 |
"basename": "unsignedShort", |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2359 |
"extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**16), |
814 | 2360 |
"facets": DECIMAL_FACETS, |
2361 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2362 |
"initial": lambda: 0, |
|
2363 |
"check": lambda x: isinstance(x, IntType) |
|
2364 |
}, |
|
2365 |
||
2366 |
"byte": { |
|
2367 |
"type": SIMPLETYPE, |
|
2368 |
"basename": "byte", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2369 |
"extract": GenerateIntegerExtraction(minInclusive=-2**7, maxExclusive=2**7), |
814 | 2370 |
"facets": DECIMAL_FACETS, |
2371 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2372 |
"initial": lambda: 0, |
|
2373 |
"check": lambda x: isinstance(x, IntType) |
|
2374 |
}, |
|
2375 |
||
2376 |
"unsignedByte": { |
|
2377 |
"type": SIMPLETYPE, |
|
2378 |
"basename": "unsignedByte", |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2379 |
"extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**8), |
814 | 2380 |
"facets": DECIMAL_FACETS, |
2381 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2382 |
"initial": lambda: 0, |
|
2383 |
"check": lambda x: isinstance(x, IntType) |
|
2384 |
}, |
|
2385 |
||
2386 |
"decimal": { |
|
2387 |
"type": SIMPLETYPE, |
|
2388 |
"basename": "decimal", |
|
2389 |
"extract": GenerateFloatExtraction("decimal"), |
|
2390 |
"facets": DECIMAL_FACETS, |
|
1373
4278d5c1e414
Fixed bug when graphic element position and size and connection points are decimal
Laurent Bessard
parents:
1322
diff
changeset
|
2391 |
"generate": GenerateFloatXMLText(decimal=3), |
814 | 2392 |
"initial": lambda: 0., |
2393 |
"check": lambda x: isinstance(x, (IntType, FloatType)) |
|
2394 |
}, |
|
2395 |
||
2396 |
"float": { |
|
2397 |
"type": SIMPLETYPE, |
|
2398 |
"basename": "float", |
|
2399 |
"extract": GenerateFloatExtraction("float", ["INF", "-INF", "NaN"]), |
|
2400 |
"facets": NUMBER_FACETS, |
|
2401 |
"generate": GenerateFloatXMLText(["INF", "-INF", "NaN"]), |
|
2402 |
"initial": lambda: 0., |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
2403 |
"check": lambda x: {"INF": True, "-INF": True, "NaN": True}.get(x, isinstance(x, (IntType, FloatType))) |
814 | 2404 |
}, |
2405 |
||
2406 |
"double": { |
|
2407 |
"type": SIMPLETYPE, |
|
2408 |
"basename": "double", |
|
2409 |
"extract": GenerateFloatExtraction("double", ["INF", "-INF", "NaN"]), |
|
2410 |
"facets": NUMBER_FACETS, |
|
2411 |
"generate": GenerateFloatXMLText(["INF", "-INF", "NaN"]), |
|
2412 |
"initial": lambda: 0., |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
2413 |
"check": lambda x: {"INF": True, "-INF": True, "NaN": True}.get(x, isinstance(x, (IntType, FloatType))) |
814 | 2414 |
}, |
2415 |
||
2416 |
"boolean": { |
|
2417 |
"type": SIMPLETYPE, |
|
2418 |
"basename": "boolean", |
|
2419 |
"extract": GetBoolean, |
|
2420 |
"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
|
2421 |
"generate": GenerateSimpleTypeXMLText(lambda x: {True: "true", False: "false"}[x]), |
814 | 2422 |
"initial": lambda: False, |
2423 |
"check": lambda x: isinstance(x, BooleanType) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2424 |
}, |
814 | 2425 |
|
2426 |
"duration": { |
|
2427 |
"type": SIMPLETYPE, |
|
2428 |
"basename": "duration", |
|
2429 |
"extract": NotSupportedYet("duration"), |
|
2430 |
"facets": NUMBER_FACETS, |
|
2431 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2432 |
"initial": lambda: "", |
|
2433 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2434 |
}, |
|
2435 |
||
2436 |
"dateTime": { |
|
2437 |
"type": SIMPLETYPE, |
|
2438 |
"basename": "dateTime", |
|
2439 |
"extract": GetDateTime, |
|
2440 |
"facets": NUMBER_FACETS, |
|
2441 |
"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
|
2442 |
"initial": lambda: datetime.datetime(1, 1, 1, 0, 0, 0, 0), |
814 | 2443 |
"check": lambda x: isinstance(x, datetime.datetime) |
2444 |
}, |
|
2445 |
||
2446 |
"date": { |
|
2447 |
"type": SIMPLETYPE, |
|
2448 |
"basename": "date", |
|
2449 |
"extract": GetDate, |
|
2450 |
"facets": NUMBER_FACETS, |
|
2451 |
"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
|
2452 |
"initial": lambda: datetime.date(1, 1, 1), |
814 | 2453 |
"check": lambda x: isinstance(x, datetime.date) |
2454 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2455 |
|
814 | 2456 |
"time": { |
2457 |
"type": SIMPLETYPE, |
|
2458 |
"basename": "time", |
|
2459 |
"extract": GetTime, |
|
2460 |
"facets": NUMBER_FACETS, |
|
2461 |
"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
|
2462 |
"initial": lambda: datetime.time(0, 0, 0, 0), |
814 | 2463 |
"check": lambda x: isinstance(x, datetime.time) |
2464 |
}, |
|
2465 |
||
2466 |
"gYear": { |
|
2467 |
"type": SIMPLETYPE, |
|
2468 |
"basename": "gYear", |
|
2469 |
"extract": NotSupportedYet("gYear"), |
|
2470 |
"facets": NUMBER_FACETS, |
|
2471 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2472 |
"initial": lambda: "", |
|
2473 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2474 |
}, |
|
2475 |
||
2476 |
"gYearMonth": { |
|
2477 |
"type": SIMPLETYPE, |
|
2478 |
"basename": "gYearMonth", |
|
2479 |
"extract": NotSupportedYet("gYearMonth"), |
|
2480 |
"facets": NUMBER_FACETS, |
|
2481 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2482 |
"initial": lambda: "", |
|
2483 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2484 |
}, |
|
2485 |
||
2486 |
"gMonth": { |
|
2487 |
"type": SIMPLETYPE, |
|
2488 |
"basename": "gMonth", |
|
2489 |
"extract": NotSupportedYet("gMonth"), |
|
2490 |
"facets": NUMBER_FACETS, |
|
2491 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2492 |
"initial": lambda: "", |
|
2493 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2494 |
}, |
|
2495 |
||
2496 |
"gMonthDay": { |
|
2497 |
"type": SIMPLETYPE, |
|
2498 |
"basename": "gMonthDay", |
|
2499 |
"extract": NotSupportedYet("gMonthDay"), |
|
2500 |
"facets": NUMBER_FACETS, |
|
2501 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2502 |
"initial": lambda: "", |
|
2503 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2504 |
}, |
|
2505 |
||
2506 |
"gDay": { |
|
2507 |
"type": SIMPLETYPE, |
|
2508 |
"basename": "gDay", |
|
2509 |
"extract": NotSupportedYet("gDay"), |
|
2510 |
"facets": NUMBER_FACETS, |
|
2511 |
"generate": GenerateSimpleTypeXMLText(str), |
|
2512 |
"initial": lambda: "", |
|
2513 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2514 |
}, |
|
2515 |
||
2516 |
"Name": { |
|
2517 |
"type": SIMPLETYPE, |
|
2518 |
"basename": "Name", |
|
2519 |
"extract": GenerateModelNameExtraction("Name", Name_model), |
|
2520 |
"facets": STRING_FACETS, |
|
2521 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2522 |
"initial": lambda: "", |
|
2523 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2524 |
}, |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1683
diff
changeset
|
2525 |
|
814 | 2526 |
"QName": { |
2527 |
"type": SIMPLETYPE, |
|
2528 |
"basename": "QName", |
|
2529 |
"extract": GenerateModelNameExtraction("QName", QName_model), |
|
2530 |
"facets": STRING_FACETS, |
|
2531 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2532 |
"initial": lambda: "", |
|
2533 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2534 |
}, |
|
2535 |
||
2536 |
"NCName": { |
|
2537 |
"type": SIMPLETYPE, |
|
2538 |
"basename": "NCName", |
|
2539 |
"extract": GenerateModelNameExtraction("NCName", NCName_model), |
|
2540 |
"facets": STRING_FACETS, |
|
2541 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2542 |
"initial": lambda: "", |
|
2543 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2544 |
}, |
|
2545 |
||
2546 |
"anyURI": { |
|
2547 |
"type": SIMPLETYPE, |
|
2548 |
"basename": "anyURI", |
|
2549 |
"extract": GenerateModelNameExtraction("anyURI", URI_model), |
|
2550 |
"facets": STRING_FACETS, |
|
2551 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2552 |
"initial": lambda: "", |
|
2553 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2554 |
}, |
|
2555 |
||
2556 |
"language": { |
|
2557 |
"type": SIMPLETYPE, |
|
2558 |
"basename": "language", |
|
2559 |
"extract": GenerateModelNameExtraction("language", LANGUAGE_model), |
|
2560 |
"facets": STRING_FACETS, |
|
2561 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2562 |
"initial": lambda: "en", |
|
2563 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2564 |
}, |
|
2565 |
||
2566 |
"ID": { |
|
2567 |
"type": SIMPLETYPE, |
|
2568 |
"basename": "ID", |
|
2569 |
"extract": GenerateModelNameExtraction("ID", Name_model), |
|
2570 |
"facets": STRING_FACETS, |
|
2571 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2572 |
"initial": lambda: "", |
|
2573 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2574 |
}, |
|
2575 |
||
2576 |
"IDREF": { |
|
2577 |
"type": SIMPLETYPE, |
|
2578 |
"basename": "IDREF", |
|
2579 |
"extract": GenerateModelNameExtraction("IDREF", Name_model), |
|
2580 |
"facets": STRING_FACETS, |
|
2581 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2582 |
"initial": lambda: "", |
|
2583 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2584 |
}, |
|
2585 |
||
2586 |
"IDREFS": { |
|
2587 |
"type": SIMPLETYPE, |
|
2588 |
"basename": "IDREFS", |
|
2589 |
"extract": GenerateModelNameExtraction("IDREFS", Names_model), |
|
2590 |
"facets": STRING_FACETS, |
|
2591 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2592 |
"initial": lambda: "", |
|
2593 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2594 |
}, |
|
2595 |
||
2596 |
"ENTITY": { |
|
2597 |
"type": SIMPLETYPE, |
|
2598 |
"basename": "ENTITY", |
|
2599 |
"extract": GenerateModelNameExtraction("ENTITY", Name_model), |
|
2600 |
"facets": STRING_FACETS, |
|
2601 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2602 |
"initial": lambda: "", |
|
2603 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2604 |
}, |
|
2605 |
||
2606 |
"ENTITIES": { |
|
2607 |
"type": SIMPLETYPE, |
|
2608 |
"basename": "ENTITIES", |
|
2609 |
"extract": GenerateModelNameExtraction("ENTITIES", Names_model), |
|
2610 |
"facets": STRING_FACETS, |
|
2611 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2612 |
"initial": lambda: "", |
|
2613 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2614 |
}, |
|
2615 |
||
2616 |
"NOTATION": { |
|
2617 |
"type": SIMPLETYPE, |
|
2618 |
"basename": "NOTATION", |
|
2619 |
"extract": GenerateModelNameExtraction("NOTATION", Name_model), |
|
2620 |
"facets": STRING_FACETS, |
|
2621 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2622 |
"initial": lambda: "", |
|
2623 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2624 |
}, |
|
2625 |
||
2626 |
"NMTOKEN": { |
|
2627 |
"type": SIMPLETYPE, |
|
2628 |
"basename": "NMTOKEN", |
|
2629 |
"extract": GenerateModelNameExtraction("NMTOKEN", NMToken_model), |
|
2630 |
"facets": STRING_FACETS, |
|
2631 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2632 |
"initial": lambda: "", |
|
2633 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2634 |
}, |
|
2635 |
||
2636 |
"NMTOKENS": { |
|
2637 |
"type": SIMPLETYPE, |
|
2638 |
"basename": "NMTOKENS", |
|
2639 |
"extract": GenerateModelNameExtraction("NMTOKENS", NMTokens_model), |
|
2640 |
"facets": STRING_FACETS, |
|
2641 |
"generate": GenerateSimpleTypeXMLText(lambda x: x), |
|
2642 |
"initial": lambda: "", |
|
2643 |
"check": lambda x: isinstance(x, (StringType, UnicodeType)) |
|
2644 |
}, |
|
2645 |
||
2646 |
# Complex Types |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
2647 |
"anyType": {"type": COMPLEXTYPE, "extract": lambda x: None}, |
814 | 2648 |
} |