193 elif facets.keys() == [facettype]: |
200 elif facets.keys() == [facettype]: |
194 facets[facettype][0].append(value) |
201 facets[facettype][0].append(value) |
195 continue |
202 continue |
196 else: |
203 else: |
197 raise ValueError("\"%s\" facet can't be defined with another facet type!" % facettype) |
204 raise ValueError("\"%s\" facet can't be defined with another facet type!" % facettype) |
198 elif facets.has_key("enumeration"): |
205 elif "enumeration" in facets: |
199 raise ValueError("\"enumeration\" facet can't be defined with another facet type!") |
206 raise ValueError("\"enumeration\" facet can't be defined with another facet type!") |
200 elif facets.has_key("pattern"): |
207 elif "pattern" in facets: |
201 raise ValueError("\"pattern\" facet can't be defined with another facet type!") |
208 raise ValueError("\"pattern\" facet can't be defined with another facet type!") |
202 elif facets.has_key(facettype): |
209 elif facettype in facets: |
203 raise ValueError("\"%s\" facet can't be defined two times!" % facettype) |
210 raise ValueError("\"%s\" facet can't be defined two times!" % facettype) |
204 elif facettype == "length": |
211 elif facettype == "length": |
205 if facets.has_key("minLength"): |
212 if "minLength" in facets: |
206 raise ValueError("\"length\" and \"minLength\" facets can't be defined at the same time!") |
213 raise ValueError("\"length\" and \"minLength\" facets can't be defined at the same time!") |
207 if facets.has_key("maxLength"): |
214 if "maxLength" in facets: |
208 raise ValueError("\"length\" and \"maxLength\" facets can't be defined at the same time!") |
215 raise ValueError("\"length\" and \"maxLength\" facets can't be defined at the same time!") |
209 try: |
216 try: |
210 value = int(value) |
217 value = int(value) |
211 except: |
218 except Exception: |
212 raise ValueError("\"length\" must be an integer!") |
219 raise ValueError("\"length\" must be an integer!") |
213 if value < 0: |
220 if value < 0: |
214 raise ValueError("\"length\" can't be negative!") |
221 raise ValueError("\"length\" can't be negative!") |
215 elif basevalue is not None and basevalue != value: |
222 elif basevalue is not None and basevalue != value: |
216 raise ValueError("\"length\" can't be different from \"length\" defined in base type!") |
223 raise ValueError("\"length\" can't be different from \"length\" defined in base type!") |
217 elif facettype == "minLength": |
224 elif facettype == "minLength": |
218 if facets.has_key("length"): |
225 if "length" in facets: |
219 raise ValueError("\"length\" and \"minLength\" facets can't be defined at the same time!") |
226 raise ValueError("\"length\" and \"minLength\" facets can't be defined at the same time!") |
220 try: |
227 try: |
221 value = int(value) |
228 value = int(value) |
222 except: |
229 except Exception: |
223 raise ValueError("\"minLength\" must be an integer!") |
230 raise ValueError("\"minLength\" must be an integer!") |
224 if value < 0: |
231 if value < 0: |
225 raise ValueError("\"minLength\" can't be negative!") |
232 raise ValueError("\"minLength\" can't be negative!") |
226 elif facets.has_key("maxLength") and value > facets["maxLength"]: |
233 elif "maxLength" in facets and value > facets["maxLength"]: |
227 raise ValueError("\"minLength\" must be lesser than or equal to \"maxLength\"!") |
234 raise ValueError("\"minLength\" must be lesser than or equal to \"maxLength\"!") |
228 elif basevalue is not None and basevalue < value: |
235 elif basevalue is not None and basevalue < value: |
229 raise ValueError("\"minLength\" can't be lesser than \"minLength\" defined in base type!") |
236 raise ValueError("\"minLength\" can't be lesser than \"minLength\" defined in base type!") |
230 elif facettype == "maxLength": |
237 elif facettype == "maxLength": |
231 if facets.has_key("length"): |
238 if "length" in facets: |
232 raise ValueError("\"length\" and \"maxLength\" facets can't be defined at the same time!") |
239 raise ValueError("\"length\" and \"maxLength\" facets can't be defined at the same time!") |
233 try: |
240 try: |
234 value = int(value) |
241 value = int(value) |
235 except: |
242 except Exception: |
236 raise ValueError("\"maxLength\" must be an integer!") |
243 raise ValueError("\"maxLength\" must be an integer!") |
237 if value < 0: |
244 if value < 0: |
238 raise ValueError("\"maxLength\" can't be negative!") |
245 raise ValueError("\"maxLength\" can't be negative!") |
239 elif facets.has_key("minLength") and value < facets["minLength"]: |
246 elif "minLength" in facets and value < facets["minLength"]: |
240 raise ValueError("\"minLength\" must be lesser than or equal to \"maxLength\"!") |
247 raise ValueError("\"minLength\" must be lesser than or equal to \"maxLength\"!") |
241 elif basevalue is not None and basevalue > value: |
248 elif basevalue is not None and basevalue > value: |
242 raise ValueError("\"maxLength\" can't be greater than \"maxLength\" defined in base type!") |
249 raise ValueError("\"maxLength\" can't be greater than \"maxLength\" defined in base type!") |
243 elif facettype == "minInclusive": |
250 elif facettype == "minInclusive": |
244 if facets.has_key("minExclusive"): |
251 if "minExclusive" in facets: |
245 raise ValueError("\"minExclusive\" and \"minInclusive\" facets can't be defined at the same time!") |
252 raise ValueError("\"minExclusive\" and \"minInclusive\" facets can't be defined at the same time!") |
246 value = basetypeinfos["extract"](facet["value"], False) |
253 value = basetypeinfos["extract"](facet["value"], False) |
247 if facets.has_key("maxInclusive") and value > facets["maxInclusive"][0]: |
254 if "maxInclusive" in facets and value > facets["maxInclusive"][0]: |
248 raise ValueError("\"minInclusive\" must be lesser than or equal to \"maxInclusive\"!") |
255 raise ValueError("\"minInclusive\" must be lesser than or equal to \"maxInclusive\"!") |
249 elif facets.has_key("maxExclusive") and value >= facets["maxExclusive"][0]: |
256 elif "maxExclusive" in facets and value >= facets["maxExclusive"][0]: |
250 raise ValueError("\"minInclusive\" must be lesser than \"maxExclusive\"!") |
257 raise ValueError("\"minInclusive\" must be lesser than \"maxExclusive\"!") |
251 elif facettype == "minExclusive": |
258 elif facettype == "minExclusive": |
252 if facets.has_key("minInclusive"): |
259 if "minInclusive" in facets: |
253 raise ValueError("\"minExclusive\" and \"minInclusive\" facets can't be defined at the same time!") |
260 raise ValueError("\"minExclusive\" and \"minInclusive\" facets can't be defined at the same time!") |
254 value = basetypeinfos["extract"](facet["value"], False) |
261 value = basetypeinfos["extract"](facet["value"], False) |
255 if facets.has_key("maxInclusive") and value >= facets["maxInclusive"][0]: |
262 if "maxInclusive" in facets and value >= facets["maxInclusive"][0]: |
256 raise ValueError("\"minExclusive\" must be lesser than \"maxInclusive\"!") |
263 raise ValueError("\"minExclusive\" must be lesser than \"maxInclusive\"!") |
257 elif facets.has_key("maxExclusive") and value >= facets["maxExclusive"][0]: |
264 elif "maxExclusive" in facets and value >= facets["maxExclusive"][0]: |
258 raise ValueError("\"minExclusive\" must be lesser than \"maxExclusive\"!") |
265 raise ValueError("\"minExclusive\" must be lesser than \"maxExclusive\"!") |
259 elif facettype == "maxInclusive": |
266 elif facettype == "maxInclusive": |
260 if facets.has_key("maxExclusive"): |
267 if "maxExclusive" in facets: |
261 raise ValueError("\"maxExclusive\" and \"maxInclusive\" facets can't be defined at the same time!") |
268 raise ValueError("\"maxExclusive\" and \"maxInclusive\" facets can't be defined at the same time!") |
262 value = basetypeinfos["extract"](facet["value"], False) |
269 value = basetypeinfos["extract"](facet["value"], False) |
263 if facets.has_key("minInclusive") and value < facets["minInclusive"][0]: |
270 if "minInclusive" in facets and value < facets["minInclusive"][0]: |
264 raise ValueError("\"minInclusive\" must be lesser than or equal to \"maxInclusive\"!") |
271 raise ValueError("\"minInclusive\" must be lesser than or equal to \"maxInclusive\"!") |
265 elif facets.has_key("minExclusive") and value <= facets["minExclusive"][0]: |
272 elif "minExclusive" in facets and value <= facets["minExclusive"][0]: |
266 raise ValueError("\"minExclusive\" must be lesser than \"maxInclusive\"!") |
273 raise ValueError("\"minExclusive\" must be lesser than \"maxInclusive\"!") |
267 elif facettype == "maxExclusive": |
274 elif facettype == "maxExclusive": |
268 if facets.has_key("maxInclusive"): |
275 if "maxInclusive" in facets: |
269 raise ValueError("\"maxExclusive\" and \"maxInclusive\" facets can't be defined at the same time!") |
276 raise ValueError("\"maxExclusive\" and \"maxInclusive\" facets can't be defined at the same time!") |
270 value = basetypeinfos["extract"](facet["value"], False) |
277 value = basetypeinfos["extract"](facet["value"], False) |
271 if facets.has_key("minInclusive") and value <= facets["minInclusive"][0]: |
278 if "minInclusive" in facets and value <= facets["minInclusive"][0]: |
272 raise ValueError("\"minInclusive\" must be lesser than \"maxExclusive\"!") |
279 raise ValueError("\"minInclusive\" must be lesser than \"maxExclusive\"!") |
273 elif facets.has_key("minExclusive") and value <= facets["minExclusive"][0]: |
280 elif "minExclusive" in facets and value <= facets["minExclusive"][0]: |
274 raise ValueError("\"minExclusive\" must be lesser than \"maxExclusive\"!") |
281 raise ValueError("\"minExclusive\" must be lesser than \"maxExclusive\"!") |
275 elif facettype == "whiteSpace": |
282 elif facettype == "whiteSpace": |
276 if basevalue == "collapse" and value in ["preserve", "replace"] or basevalue == "replace" and value == "preserve": |
283 if basevalue == "collapse" and value in ["preserve", "replace"] or basevalue == "replace" and value == "preserve": |
277 raise ValueError("\"whiteSpace\" is incompatible with \"whiteSpace\" defined in base type!") |
284 raise ValueError("\"whiteSpace\" is incompatible with \"whiteSpace\" defined in base type!") |
278 elif facettype == "totalDigits": |
285 elif facettype == "totalDigits": |
279 if facets.has_key("fractionDigits") and value <= facets["fractionDigits"][0]: |
286 if "fractionDigits" in facets and value <= facets["fractionDigits"][0]: |
280 raise ValueError("\"fractionDigits\" must be lesser than or equal to \"totalDigits\"!") |
287 raise ValueError("\"fractionDigits\" must be lesser than or equal to \"totalDigits\"!") |
281 elif basevalue is not None and value > basevalue: |
288 elif basevalue is not None and value > basevalue: |
282 raise ValueError("\"totalDigits\" can't be greater than \"totalDigits\" defined in base type!") |
289 raise ValueError("\"totalDigits\" can't be greater than \"totalDigits\" defined in base type!") |
283 elif facettype == "fractionDigits": |
290 elif facettype == "fractionDigits": |
284 if facets.has_key("totalDigits") and value <= facets["totalDigits"][0]: |
291 if "totalDigits" in facets and value <= facets["totalDigits"][0]: |
285 raise ValueError("\"fractionDigits\" must be lesser than or equal to \"totalDigits\"!") |
292 raise ValueError("\"fractionDigits\" must be lesser than or equal to \"totalDigits\"!") |
286 elif basevalue is not None and value > basevalue: |
293 elif basevalue is not None and value > basevalue: |
287 raise ValueError("\"totalDigits\" can't be greater than \"totalDigits\" defined in base type!") |
294 raise ValueError("\"totalDigits\" can't be greater than \"totalDigits\" defined in base type!") |
288 facets[facettype] = (value, facet.get("fixed", False)) |
295 facets[facettype] = (value, facet.get("fixed", False)) |
289 |
296 |
290 # Report not redefined facet from base type to new created type |
297 # Report not redefined facet from base type to new created type |
291 for facettype, facetvalue in basetypeinfos["facets"].items(): |
298 for facettype, facetvalue in basetypeinfos["facets"].items(): |
292 if not facets.has_key(facettype): |
299 if facettype not in facets: |
293 facets[facettype] = facetvalue |
300 facets[facettype] = facetvalue |
294 |
301 |
295 # Generate extract value for new created type |
302 # Generate extract value for new created type |
296 def ExtractSimpleTypeValue(attr, extract=True): |
303 def ExtractSimpleTypeValue(attr, extract=True): |
297 value = basetypeinfos["extract"](attr, extract) |
304 value = basetypeinfos["extract"](attr, extract) |
298 for facetname, (facetvalue, facetfixed) in facets.items(): |
305 for facetname, (facetvalue, facetfixed) in facets.items(): |
299 if facetvalue is not None: |
306 if facetvalue is not None: |
370 return facetvalue |
377 return facetvalue |
371 elif facetname == "minExclusive" and facetvalue >= 0: |
378 elif facetname == "minExclusive" and facetvalue >= 0: |
372 return facetvalue + 1 |
379 return facetvalue + 1 |
373 elif facetname == "maxInclusive" and facetvalue < 0: |
380 elif facetname == "maxInclusive" and facetvalue < 0: |
374 return facetvalue |
381 return facetvalue |
375 elif facetname == "maxExclusive" and facetvalue <= 0: |
382 elif facetname == "maxExclusive" and facetvalue <= 0: |
376 return facetvalue - 1 |
383 return facetvalue - 1 |
377 return basetypeinfos["initial"]() |
384 return basetypeinfos["initial"]() |
378 |
385 |
379 GenerateSimpleType = basetypeinfos["generate"] |
386 GenerateSimpleType = basetypeinfos["generate"] |
380 |
387 |
381 elif typeinfos["type"] == "list": |
388 elif typeinfos["type"] == "list": |
382 # Search for item type definition |
389 # Search for item type definition |
383 if isinstance(typeinfos["itemType"], (StringType, UnicodeType)): |
390 if isinstance(typeinfos["itemType"], (StringType, UnicodeType)): |
384 itemtypeinfos = factory.FindSchemaElement(typeinfos["itemType"], SIMPLETYPE) |
391 itemtypeinfos = factory.FindSchemaElement(typeinfos["itemType"], SIMPLETYPE) |
385 if itemtypeinfos is None: |
392 if itemtypeinfos is None: |
386 raise "\"%s\" isn't defined!" % typeinfos["itemType"] |
393 raise "\"%s\" isn't defined!" % typeinfos["itemType"] |
387 else: |
394 else: |
388 itemtypeinfos = typeinfos["itemType"] |
395 itemtypeinfos = typeinfos["itemType"] |
389 |
396 |
390 # Check that item type is a simple type |
397 # Check that item type is a simple type |
391 if itemtypeinfos["type"] != SIMPLETYPE: |
398 if itemtypeinfos["type"] != SIMPLETYPE: |
392 raise ValueError, "Item type given isn't a simpleType!" |
399 raise ValueError("Item type given isn't a simpleType!") |
393 |
400 |
394 simpleType["basename"] = "list" |
401 simpleType["basename"] = "list" |
395 |
402 |
396 # Check that derivation is allowed |
403 # Check that derivation is allowed |
397 if itemtypeinfos.has_key("final"): |
404 if "final" in itemtypeinfos: |
398 if itemtypeinfos["final"].has_key("#all"): |
405 if "#all" in itemtypeinfos["final"]: |
399 raise ValueError("Item type can't be derivated!") |
406 raise ValueError("Item type can't be derivated!") |
400 if itemtypeinfos["final"].has_key("list"): |
407 if "list" in itemtypeinfos["final"]: |
401 raise ValueError("Item type can't be derivated by list!") |
408 raise ValueError("Item type can't be derivated by list!") |
402 |
409 |
403 # Generate extract value for new created type |
410 # Generate extract value for new created type |
404 def ExtractSimpleTypeValue(attr, extract = True): |
411 def ExtractSimpleTypeValue(attr, extract=True): |
405 values = [] |
412 values = [] |
406 for value in GetToken(attr, extract).split(" "): |
413 for value in GetToken(attr, extract).split(" "): |
407 values.append(itemtypeinfos["extract"](value, False)) |
414 values.append(itemtypeinfos["extract"](value, False)) |
408 return values |
415 return values |
409 |
416 |
410 def CheckSimpleTypeValue(value): |
417 def CheckSimpleTypeValue(value): |
411 for item in value: |
418 for item in value: |
412 result = itemtypeinfos["check"](item) |
419 result = itemtypeinfos["check"](item) |
413 if not result: |
420 if not result: |
414 return result |
421 return result |
415 return True |
422 return True |
416 |
423 |
417 SimpleTypeInitialValue = lambda: [] |
424 def SimpleTypeInitialValue(): |
418 |
425 return [] |
|
426 |
419 GenerateSimpleType = GenerateSimpleTypeXMLText(lambda x: " ".join(map(itemtypeinfos["generate"], x))) |
427 GenerateSimpleType = GenerateSimpleTypeXMLText(lambda x: " ".join(map(itemtypeinfos["generate"], x))) |
420 |
428 |
421 facets = GenerateDictFacets(["length", "maxLength", "minLength", "enumeration", "pattern"]) |
429 facets = GenerateDictFacets(["length", "maxLength", "minLength", "enumeration", "pattern"]) |
422 facets["whiteSpace"] = ("collapse", False) |
430 facets["whiteSpace"] = ("collapse", False) |
423 |
431 |
424 elif typeinfos["type"] == "union": |
432 elif typeinfos["type"] == "union": |
425 # Search for member types definition |
433 # Search for member types definition |
426 membertypesinfos = [] |
434 membertypesinfos = [] |
427 for membertype in typeinfos["memberTypes"]: |
435 for membertype in typeinfos["memberTypes"]: |
428 if isinstance(membertype, (StringType, UnicodeType)): |
436 if isinstance(membertype, (StringType, UnicodeType)): |
429 infos = factory.FindSchemaElement(membertype, SIMPLETYPE) |
437 infos = factory.FindSchemaElement(membertype, SIMPLETYPE) |
430 if infos is None: |
438 if infos is None: |
431 raise ValueError("\"%s\" isn't defined!" % membertype) |
439 raise ValueError("\"%s\" isn't defined!" % membertype) |
432 else: |
440 else: |
433 infos = membertype |
441 infos = membertype |
434 |
442 |
435 # Check that member type is a simple type |
443 # Check that member type is a simple type |
436 if infos["type"] != SIMPLETYPE: |
444 if infos["type"] != SIMPLETYPE: |
437 raise ValueError("Member type given isn't a simpleType!") |
445 raise ValueError("Member type given isn't a simpleType!") |
438 |
446 |
439 # Check that derivation is allowed |
447 # Check that derivation is allowed |
440 if infos.has_key("final"): |
448 if "final" in infos: |
441 if infos["final"].has_key("#all"): |
449 if "#all" in infos["final"]: |
442 raise ValueError("Item type can't be derivated!") |
450 raise ValueError("Item type can't be derivated!") |
443 if infos["final"].has_key("union"): |
451 if "union" in infos["final"]: |
444 raise ValueError("Member type can't be derivated by union!") |
452 raise ValueError("Member type can't be derivated by union!") |
445 |
453 |
446 membertypesinfos.append(infos) |
454 membertypesinfos.append(infos) |
447 |
455 |
448 simpleType["basename"] = "union" |
456 simpleType["basename"] = "union" |
449 |
457 |
450 # Generate extract value for new created type |
458 # Generate extract value for new created type |
451 def ExtractSimpleTypeValue(attr, extract = True): |
459 def ExtractSimpleTypeValue(attr, extract=True): |
452 if extract: |
460 if extract: |
453 value = GetAttributeValue(attr) |
461 value = GetAttributeValue(attr) |
454 else: |
462 else: |
455 value = attr |
463 value = attr |
456 for infos in membertypesinfos: |
464 for infos in membertypesinfos: |
457 try: |
465 try: |
458 return infos["extract"](attr, False) |
466 return infos["extract"](attr, False) |
459 except: |
467 except Exception: |
460 pass |
468 pass |
461 raise ValueError("\"%s\" isn't valid for type defined for union!") |
469 raise ValueError("\"%s\" isn't valid for type defined for union!") |
462 |
470 |
463 def CheckSimpleTypeValue(value): |
471 def CheckSimpleTypeValue(value): |
464 for infos in membertypesinfos: |
472 for infos in membertypesinfos: |
465 result = infos["check"](value) |
473 result = infos["check"](value) |
466 if result: |
474 if result: |
467 return result |
475 return result |
468 return False |
476 return False |
469 |
477 |
470 SimpleTypeInitialValue = membertypesinfos[0]["initial"] |
478 SimpleTypeInitialValue = membertypesinfos[0]["initial"] |
471 |
479 |
472 def GenerateSimpleTypeFunction(value): |
480 def GenerateSimpleTypeFunction(value): |
473 if isinstance(value, BooleanType): |
481 if isinstance(value, BooleanType): |
474 return {True: "true", False: "false"}[value] |
482 return {True: "true", False: "false"}[value] |
475 else: |
483 else: |
476 return str(value) |
484 return str(value) |
477 GenerateSimpleType = GenerateSimpleTypeXMLText(GenerateSimpleTypeFunction) |
485 GenerateSimpleType = GenerateSimpleTypeXMLText(GenerateSimpleTypeFunction) |
478 |
486 |
479 facets = GenerateDictFacets(["pattern", "enumeration"]) |
487 facets = GenerateDictFacets(["pattern", "enumeration"]) |
480 |
488 |
481 simpleType["facets"] = facets |
489 simpleType["facets"] = facets |
482 simpleType["extract"] = ExtractSimpleTypeValue |
490 simpleType["extract"] = ExtractSimpleTypeValue |
483 simpleType["initial"] = SimpleTypeInitialValue |
491 simpleType["initial"] = SimpleTypeInitialValue |
484 simpleType["check"] = CheckSimpleTypeValue |
492 simpleType["check"] = CheckSimpleTypeValue |
485 simpleType["generate"] = GenerateSimpleType |
493 simpleType["generate"] = GenerateSimpleType |
486 return simpleType |
494 return simpleType |
487 |
495 |
|
496 |
488 def ReduceSimpleType(factory, attributes, elements): |
497 def ReduceSimpleType(factory, attributes, elements): |
489 # Reduce all the simple type children |
498 # Reduce all the simple type children |
490 annotations, children = factory.ReduceElements(elements) |
499 annotations, children = factory.ReduceElements(elements) |
491 |
500 |
492 simpleType = CreateSimpleType(factory, attributes, children[0]) |
501 simpleType = CreateSimpleType(factory, attributes, children[0]) |
493 simpleType["doc"] = annotations |
502 simpleType["doc"] = annotations |
494 |
503 |
495 return simpleType |
504 return simpleType |
496 |
505 |
497 # Complex type |
506 # Complex type |
|
507 |
498 |
508 |
499 def ExtractAttributes(factory, elements, base=None): |
509 def ExtractAttributes(factory, elements, base=None): |
500 attrs = [] |
510 attrs = [] |
501 attrnames = {} |
511 attrnames = {} |
502 if base is not None: |
512 if base is not None: |
503 basetypeinfos = factory.FindSchemaElement(base) |
513 basetypeinfos = factory.FindSchemaElement(base) |
504 if not isinstance(basetypeinfos, (UnicodeType, StringType)) and basetypeinfos["type"] == COMPLEXTYPE: |
514 if not isinstance(basetypeinfos, (UnicodeType, StringType)) and basetypeinfos["type"] == COMPLEXTYPE: |
505 attrnames = dict(map(lambda x:(x["name"], True), basetypeinfos["attributes"])) |
515 attrnames = dict(map(lambda x: (x["name"], True), basetypeinfos["attributes"])) |
506 |
516 |
507 for element in elements: |
517 for element in elements: |
508 if element["type"] == ATTRIBUTE: |
518 if element["type"] == ATTRIBUTE: |
509 if attrnames.get(element["name"], False): |
519 if attrnames.get(element["name"], False): |
510 raise ValueError("\"%s\" attribute has been defined two times!" % element["name"]) |
520 raise ValueError("\"%s\" attribute has been defined two times!" % element["name"]) |
511 else: |
521 else: |
659 |
669 |
660 |
670 |
661 # Attribute elements |
671 # Attribute elements |
662 |
672 |
663 def ReduceAnyAttribute(factory, attributes, elements): |
673 def ReduceAnyAttribute(factory, attributes, elements): |
664 return {"type" : "anyAttribute"} |
674 return {"type": "anyAttribute"} |
665 |
675 |
666 |
676 |
667 def ReduceAttribute(factory, attributes, elements): |
677 def ReduceAttribute(factory, attributes, elements): |
668 annotations, children = factory.ReduceElements(elements) |
678 annotations, children = factory.ReduceElements(elements) |
669 |
679 |
670 if attributes.has_key("default"): |
680 if "default" in attributes: |
671 if attributes.has_key("fixed"): |
681 if "fixed" in attributes: |
672 raise ValueError("\"default\" and \"fixed\" can't be defined at the same time!") |
682 raise ValueError("\"default\" and \"fixed\" can't be defined at the same time!") |
673 elif attributes.get("use", "optional") != "optional": |
683 elif attributes.get("use", "optional") != "optional": |
674 raise ValueError("if \"default\" present, \"use\" can only have the value \"optional\"!") |
684 raise ValueError("if \"default\" present, \"use\" can only have the value \"optional\"!") |
675 |
685 |
676 attribute = {"type": ATTRIBUTE, "attr_type": attributes.get("type", None), "doc": annotations} |
686 attribute = {"type": ATTRIBUTE, "attr_type": attributes.get("type", None), "doc": annotations} |
677 if len(children) > 0: |
687 if len(children) > 0: |
678 if attribute["attr_type"] is None: |
688 if attribute["attr_type"] is None: |
679 attribute["attr_type"] = children[0] |
689 attribute["attr_type"] = children[0] |
680 else: |
690 else: |
681 raise ValueError("Only one type can be defined for attribute!") |
691 raise ValueError("Only one type can be defined for attribute!") |
682 |
692 |
683 if attributes.has_key("ref"): |
693 if "ref" in attributes: |
684 if attributes.has_key("name"): |
694 if "name" in attributes: |
685 raise ValueError("\"ref\" and \"name\" can't be defined at the same time!") |
695 raise ValueError("\"ref\" and \"name\" can't be defined at the same time!") |
686 elif attributes.has_key("form"): |
696 elif "form" in attributes: |
687 raise ValueError("\"ref\" and \"form\" can't be defined at the same time!") |
697 raise ValueError("\"ref\" and \"form\" can't be defined at the same time!") |
688 elif attribute["attr_type"] is not None: |
698 elif attribute["attr_type"] is not None: |
689 raise ValueError("if \"ref\" is present, no type can be defined!") |
699 raise ValueError("if \"ref\" is present, no type can be defined!") |
690 elif attribute["attr_type"] is None: |
700 elif attribute["attr_type"] is None: |
691 raise ValueError("No type has been defined for attribute \"%s\"!" % attributes["name"]) |
701 raise ValueError("No type has been defined for attribute \"%s\"!" % attributes["name"]) |
692 |
702 |
693 if attributes.has_key("type"): |
703 if "type" in attributes: |
694 tmp_attrs = attributes.copy() |
704 tmp_attrs = attributes.copy() |
695 tmp_attrs.pop("type") |
705 tmp_attrs.pop("type") |
696 attribute.update(tmp_attrs) |
706 attribute.update(tmp_attrs) |
697 else: |
707 else: |
698 attribute.update(attributes) |
708 attribute.update(attributes) |
699 return attribute |
709 return attribute |
700 |
710 |
701 |
711 |
702 def ReduceAttributeGroup(factory, attributes, elements): |
712 def ReduceAttributeGroup(factory, attributes, elements): |
703 annotations, children = factory.ReduceElements(elements) |
713 annotations, children = factory.ReduceElements(elements) |
704 if attributes.has_key("ref"): |
714 if "ref" in attributes: |
705 return {"type": "attributeGroup", "ref": attributes["ref"], "doc": annotations} |
715 return {"type": "attributeGroup", "ref": attributes["ref"], "doc": annotations} |
706 else: |
716 else: |
707 return {"type": ATTRIBUTESGROUP, "attributes": ExtractAttributes(factory, children), "doc": annotations} |
717 return {"type": ATTRIBUTESGROUP, "attributes": ExtractAttributes(factory, children), "doc": annotations} |
708 |
718 |
709 |
719 |
710 # Elements groups |
720 # Elements groups |
711 |
721 |
712 def ReduceAny(factory, attributes, elements): |
722 def ReduceAny(factory, attributes, elements): |
713 annotations, children = factory.ReduceElements(elements) |
723 annotations, children = factory.ReduceElements(elements) |
714 |
724 |
715 any = {"type": ANY, "doc": annotations} |
725 any = {"type": ANY, "doc": annotations} |
716 any.update(attributes) |
726 any.update(attributes) |
717 return any |
727 return any |
718 |
728 |
|
729 |
719 def ReduceElement(factory, attributes, elements): |
730 def ReduceElement(factory, attributes, elements): |
720 annotations, children = factory.ReduceElements(elements) |
731 annotations, children = factory.ReduceElements(elements) |
721 |
732 |
722 types = [] |
733 types = [] |
723 constraints = [] |
734 constraints = [] |
724 for child in children: |
735 for child in children: |
725 if child["type"] == CONSTRAINT: |
736 if child["type"] == CONSTRAINT: |
726 constraints.append(child) |
737 constraints.append(child) |
727 else: |
738 else: |
728 types.append(child) |
739 types.append(child) |
729 |
740 |
730 if attributes.has_key("default") and attributes.has_key("fixed"): |
741 if "default" in attributes and "fixed" in attributes: |
731 raise ValueError("\"default\" and \"fixed\" can't be defined at the same time!") |
742 raise ValueError("\"default\" and \"fixed\" can't be defined at the same time!") |
732 |
743 |
733 if attributes.has_key("ref"): |
744 if "ref" in attributes: |
734 for attr in ["name", "default", "fixed", "form", "block", "type"]: |
745 for attr in ["name", "default", "fixed", "form", "block", "type"]: |
735 if attributes.has_key(attr): |
746 if attr in attributes: |
736 raise ValueError("\"ref\" and \"%s\" can't be defined at the same time!" % attr) |
747 raise ValueError("\"ref\" and \"%s\" can't be defined at the same time!" % attr) |
737 if attributes.has_key("nillable"): |
748 if "nillable" in attributes: |
738 raise ValueError("\"ref\" and \"nillable\" can't be defined at the same time!") |
749 raise ValueError("\"ref\" and \"nillable\" can't be defined at the same time!") |
739 if len(types) > 0: |
750 if len(types) > 0: |
740 raise ValueError("No type and no constraints can be defined where \"ref\" is defined!") |
751 raise ValueError("No type and no constraints can be defined where \"ref\" is defined!") |
741 |
752 |
742 infos = factory.FindSchemaElement(attributes["ref"], ELEMENT) |
753 infos = factory.FindSchemaElement(attributes["ref"], ELEMENT) |
743 if infos is not None: |
754 if infos is not None: |
744 element = infos.copy() |
755 element = infos.copy() |
745 element["constraints"] = constraints |
756 element["constraints"] = constraints |
746 element["minOccurs"] = attributes["minOccurs"] |
757 element["minOccurs"] = attributes["minOccurs"] |
747 element["maxOccurs"] = attributes["maxOccurs"] |
758 element["maxOccurs"] = attributes["maxOccurs"] |
748 return element |
759 return element |
749 else: |
760 else: |
750 raise ValueError("\"%s\" base type isn't defined or circular referenced!" % name) |
761 raise ValueError("\"%s\" base type isn't defined or circular referenced!" % name) |
751 |
762 |
752 elif attributes.has_key("name"): |
763 elif "name" in attributes: |
753 element = {"type": ELEMENT, "elmt_type": attributes.get("type", None), "constraints": constraints, "doc": annotations} |
764 element = {"type": ELEMENT, "elmt_type": attributes.get("type", None), "constraints": constraints, "doc": annotations} |
754 if len(types) > 0: |
765 if len(types) > 0: |
755 if element["elmt_type"] is None: |
766 if element["elmt_type"] is None: |
756 element["elmt_type"] = types[0] |
767 element["elmt_type"] = types[0] |
757 else: |
768 else: |
758 raise ValueError("Only one type can be defined for attribute!") |
769 raise ValueError("Only one type can be defined for attribute!") |
759 elif element["elmt_type"] is None: |
770 elif element["elmt_type"] is None: |
760 element["elmt_type"] = "tag" |
771 element["elmt_type"] = "tag" |
761 element["type"] = TAG |
772 element["type"] = TAG |
762 |
773 |
763 if attributes.has_key("type"): |
774 if "type" in attributes: |
764 tmp_attrs = attributes.copy() |
775 tmp_attrs = attributes.copy() |
765 tmp_attrs.pop("type") |
776 tmp_attrs.pop("type") |
766 element.update(tmp_attrs) |
777 element.update(tmp_attrs) |
767 else: |
778 else: |
768 element.update(attributes) |
779 element.update(attributes) |
769 return element |
780 return element |
770 else: |
781 else: |
771 raise ValueError("\"Element\" must have at least a \"ref\" or a \"name\" defined!") |
782 raise ValueError("\"Element\" must have at least a \"ref\" or a \"name\" defined!") |
772 |
783 |
|
784 |
773 def ReduceAll(factory, attributes, elements): |
785 def ReduceAll(factory, attributes, elements): |
774 annotations, children = factory.ReduceElements(elements) |
786 annotations, children = factory.ReduceElements(elements) |
775 |
787 |
776 for child in children: |
788 for child in children: |
777 if children["maxOccurs"] == "unbounded" or children["maxOccurs"] > 1: |
789 if children["maxOccurs"] == "unbounded" or children["maxOccurs"] > 1: |
778 raise ValueError("\"all\" item can't have \"maxOccurs\" attribute greater than 1!") |
790 raise ValueError("\"all\" item can't have \"maxOccurs\" attribute greater than 1!") |
779 |
791 |
780 return {"type": "all", "elements": children, "minOccurs": attributes["minOccurs"], |
792 return {"type": "all", "elements": children, "minOccurs": attributes["minOccurs"], |
781 "maxOccurs": attributes["maxOccurs"], "order": False, "doc": annotations} |
793 "maxOccurs": attributes["maxOccurs"], "order": False, "doc": annotations} |
782 |
794 |
783 |
795 |
784 def ReduceChoice(factory, attributes, elements): |
796 def ReduceChoice(factory, attributes, elements): |
785 annotations, children = factory.ReduceElements(elements) |
797 annotations, children = factory.ReduceElements(elements) |
786 |
798 |
787 choices = [] |
799 choices = [] |
788 for child in children: |
800 for child in children: |
789 if child["type"] in [ELEMENT, ANY, TAG]: |
801 if child["type"] in [ELEMENT, ANY, TAG]: |
790 choices.append(child) |
802 choices.append(child) |
791 elif child["type"] == "sequence": |
803 elif child["type"] == "sequence": |
792 child["minOccurs"] = child["maxOccurs"] = 1 |
804 child["minOccurs"] = child["maxOccurs"] = 1 |
793 choices.append(child) |
805 choices.append(child) |
794 #raise ValueError("\"sequence\" in \"choice\" is not supported. Create instead a new complex type!") |
806 # raise ValueError("\"sequence\" in \"choice\" is not supported. Create instead a new complex type!") |
795 elif child["type"] == CHOICE: |
807 elif child["type"] == CHOICE: |
796 choices.extend(child["choices"]) |
808 choices.extend(child["choices"]) |
797 elif child["type"] == "group": |
809 elif child["type"] == "group": |
798 elmtgroup = factory.FindSchemaElement(child["ref"], ELEMENTSGROUP) |
810 elmtgroup = factory.FindSchemaElement(child["ref"], ELEMENTSGROUP) |
799 if not elmtgroup.has_key("choices"): |
811 if "choices" not in elmtgroup: |
800 raise ValueError("Only group composed of \"choice\" can be referenced in \"choice\" element!") |
812 raise ValueError("Only group composed of \"choice\" can be referenced in \"choice\" element!") |
801 choices_tmp = [] |
813 choices_tmp = [] |
802 for choice in elmtgroup["choices"]: |
814 for choice in elmtgroup["choices"]: |
803 if not isinstance(choice["elmt_type"], (UnicodeType, StringType)) and choice["elmt_type"]["type"] == COMPLEXTYPE: |
815 if not isinstance(choice["elmt_type"], (UnicodeType, StringType)) and choice["elmt_type"]["type"] == COMPLEXTYPE: |
804 elmt_type = "%s_%s" % (elmtgroup["name"], choice["name"]) |
816 elmt_type = "%s_%s" % (elmtgroup["name"], choice["name"]) |
808 new_choice["elmt_type"] = elmt_type |
820 new_choice["elmt_type"] = elmt_type |
809 choices_tmp.append(new_choice) |
821 choices_tmp.append(new_choice) |
810 else: |
822 else: |
811 choices_tmp.append(choice) |
823 choices_tmp.append(choice) |
812 choices.extend(choices_tmp) |
824 choices.extend(choices_tmp) |
813 |
825 |
814 for choice in choices: |
826 for choice in choices: |
815 attributes["minOccurs"] = min(attributes["minOccurs"], choice["minOccurs"]) |
827 attributes["minOccurs"] = min(attributes["minOccurs"], choice["minOccurs"]) |
816 choice["minOccurs"] = 1 |
828 choice["minOccurs"] = 1 |
817 |
829 |
818 return {"type": CHOICE, "choices": choices, "minOccurs": attributes["minOccurs"], |
830 return {"type": CHOICE, "choices": choices, "minOccurs": attributes["minOccurs"], |
819 "maxOccurs": attributes["maxOccurs"], "doc": annotations} |
831 "maxOccurs": attributes["maxOccurs"], "doc": annotations} |
820 |
832 |
821 |
833 |
822 def ReduceSequence(factory, attributes, elements): |
834 def ReduceSequence(factory, attributes, elements): |
823 annotations, children = factory.ReduceElements(elements) |
835 annotations, children = factory.ReduceElements(elements) |
824 |
836 |
825 sequence = [] |
837 sequence = [] |
826 for child in children: |
838 for child in children: |
827 if child["type"] in [ELEMENT, ANY, TAG, CHOICE]: |
839 if child["type"] in [ELEMENT, ANY, TAG, CHOICE]: |
828 sequence.append(child) |
840 sequence.append(child) |
829 elif child["type"] == "sequence": |
841 elif child["type"] == "sequence": |
830 sequence.extend(child["elements"]) |
842 sequence.extend(child["elements"]) |
831 elif child["type"] == "group": |
843 elif child["type"] == "group": |
832 elmtgroup = factory.FindSchemaElement(child["ref"], ELEMENTSGROUP) |
844 elmtgroup = factory.FindSchemaElement(child["ref"], ELEMENTSGROUP) |
833 if not elmtgroup.has_key("elements") or not elmtgroup["order"]: |
845 if "elements" not in elmtgroup or not elmtgroup["order"]: |
834 raise ValueError("Only group composed of \"sequence\" can be referenced in \"sequence\" element!") |
846 raise ValueError("Only group composed of \"sequence\" can be referenced in \"sequence\" element!") |
835 elements_tmp = [] |
847 elements_tmp = [] |
836 for element in elmtgroup["elements"]: |
848 for element in elmtgroup["elements"]: |
837 if not isinstance(element["elmt_type"], (UnicodeType, StringType)) and element["elmt_type"]["type"] == COMPLEXTYPE: |
849 if not isinstance(element["elmt_type"], (UnicodeType, StringType)) and element["elmt_type"]["type"] == COMPLEXTYPE: |
838 elmt_type = "%s_%s"%(elmtgroup["name"], element["name"]) |
850 elmt_type = "%s_%s" % (elmtgroup["name"], element["name"]) |
839 if factory.TargetNamespace is not None: |
851 if factory.TargetNamespace is not None: |
840 elmt_type = "%s:%s" % (factory.TargetNamespace, elmt_type) |
852 elmt_type = "%s:%s" % (factory.TargetNamespace, elmt_type) |
841 new_element = element.copy() |
853 new_element = element.copy() |
842 new_element["elmt_type"] = elmt_type |
854 new_element["elmt_type"] = elmt_type |
843 elements_tmp.append(new_element) |
855 elements_tmp.append(new_element) |
844 else: |
856 else: |
845 elements_tmp.append(element) |
857 elements_tmp.append(element) |
846 sequence.extend(elements_tmp) |
858 sequence.extend(elements_tmp) |
847 |
859 |
848 return {"type": "sequence", "elements": sequence, "minOccurs": attributes["minOccurs"], |
860 return {"type": "sequence", "elements": sequence, "minOccurs": attributes["minOccurs"], |
849 "maxOccurs": attributes["maxOccurs"], "order": True, "doc": annotations} |
861 "maxOccurs": attributes["maxOccurs"], "order": True, "doc": annotations} |
850 |
862 |
851 |
863 |
852 def ReduceGroup(factory, attributes, elements): |
864 def ReduceGroup(factory, attributes, elements): |
853 annotations, children = factory.ReduceElements(elements) |
865 annotations, children = factory.ReduceElements(elements) |
854 |
866 |
855 if attributes.has_key("ref"): |
867 if "ref" in attributes: |
856 return {"type": "group", "ref": attributes["ref"], "doc": annotations} |
868 return {"type": "group", "ref": attributes["ref"], "doc": annotations} |
857 else: |
869 else: |
858 element = children[0] |
870 element = children[0] |
859 group = {"type": ELEMENTSGROUP, "doc": annotations} |
871 group = {"type": ELEMENTSGROUP, "doc": annotations} |
860 if element["type"] == CHOICE: |
872 if element["type"] == CHOICE: |
864 group.update(attributes) |
876 group.update(attributes) |
865 return group |
877 return group |
866 |
878 |
867 # Constraint elements |
879 # Constraint elements |
868 |
880 |
|
881 |
869 def ReduceUnique(factory, attributes, elements): |
882 def ReduceUnique(factory, attributes, elements): |
870 annotations, children = factory.ReduceElements(elements) |
883 annotations, children = factory.ReduceElements(elements) |
871 |
884 |
872 unique = {"type": CONSTRAINT, "const_type": "unique", "selector": children[0], "fields": children[1:]} |
885 unique = {"type": CONSTRAINT, "const_type": "unique", "selector": children[0], "fields": children[1:]} |
873 unique.update(attributes) |
886 unique.update(attributes) |
874 return unique |
887 return unique |
875 |
888 |
|
889 |
876 def ReduceKey(factory, attributes, elements): |
890 def ReduceKey(factory, attributes, elements): |
877 annotations, children = factory.ReduceElements(elements) |
891 annotations, children = factory.ReduceElements(elements) |
878 |
892 |
879 key = {"type": CONSTRAINT, "const_type": "key", "selector": children[0], "fields": children[1:]} |
893 key = {"type": CONSTRAINT, "const_type": "key", "selector": children[0], "fields": children[1:]} |
880 key.update(attributes) |
894 key.update(attributes) |
881 return key |
895 return key |
882 |
896 |
|
897 |
883 def ReduceKeyRef(factory, attributes, elements): |
898 def ReduceKeyRef(factory, attributes, elements): |
884 annotations, children = factory.ReduceElements(elements) |
899 annotations, children = factory.ReduceElements(elements) |
885 |
900 |
886 keyref = {"type": CONSTRAINT, "const_type": "keyref", "selector": children[0], "fields": children[1:]} |
901 keyref = {"type": CONSTRAINT, "const_type": "keyref", "selector": children[0], "fields": children[1:]} |
887 keyref.update(attributes) |
902 keyref.update(attributes) |
888 return keyref |
903 return keyref |
889 |
904 |
|
905 |
890 def ReduceSelector(factory, attributes, elements): |
906 def ReduceSelector(factory, attributes, elements): |
891 annotations, children = factory.ReduceElements(elements) |
907 annotations, children = factory.ReduceElements(elements) |
892 |
908 |
893 selector = {"type": CONSTRAINT, "const_type": "selector"} |
909 selector = {"type": CONSTRAINT, "const_type": "selector"} |
894 selector.update(attributes) |
910 selector.update(attributes) |
895 return selector |
911 return selector |
896 |
912 |
|
913 |
897 def ReduceField(factory, attributes, elements): |
914 def ReduceField(factory, attributes, elements): |
898 annotations, children = factory.ReduceElements(elements) |
915 annotations, children = factory.ReduceElements(elements) |
899 |
916 |
900 field = {"type": CONSTRAINT, "const_type": "field"} |
917 field = {"type": CONSTRAINT, "const_type": "field"} |
901 field.update(attributes) |
918 field.update(attributes) |
902 return field |
919 return field |
903 |
920 |
904 |
921 |
905 # Inclusion elements |
922 # Inclusion elements |
906 |
923 |
907 def ReduceImport(factory, attributes, elements): |
924 def ReduceImport(factory, attributes, elements): |
908 annotations, children = factory.ReduceElements(elements) |
925 annotations, children = factory.ReduceElements(elements) |
909 raise ValueError("\"import\" element isn't supported yet!") |
926 raise ValueError("\"import\" element isn't supported yet!") |
910 |
927 |
|
928 |
911 def ReduceInclude(factory, attributes, elements): |
929 def ReduceInclude(factory, attributes, elements): |
912 annotations, children = factory.ReduceElements(elements) |
930 annotations, children = factory.ReduceElements(elements) |
913 |
931 |
914 if factory.FileName is None: |
932 if factory.FileName is None: |
915 raise ValueError("Include in XSD string not yet supported") |
933 raise ValueError("Include in XSD string not yet supported") |
916 filepath = attributes["schemaLocation"] |
934 filepath = attributes["schemaLocation"] |
917 if filepath is not None and not os.path.exists(filepath): |
935 if filepath is not None and not os.path.exists(filepath): |
918 filepath = os.path.join(factory.BaseFolder, filepath) |
936 filepath = os.path.join(factory.BaseFolder, filepath) |
1088 if element_infos is not None: |
1109 if element_infos is not None: |
1089 self.Namespaces[self.TargetNamespace][element_name] = element_infos |
1110 self.Namespaces[self.TargetNamespace][element_name] = element_infos |
1090 return element_infos |
1111 return element_infos |
1091 return None |
1112 return None |
1092 |
1113 |
1093 """ |
1114 |
1094 This function opens the xsd file and generate a xml parser with class lookup from |
|
1095 the xml tree |
|
1096 """ |
|
1097 def GenerateParserFromXSD(filepath): |
1115 def GenerateParserFromXSD(filepath): |
|
1116 """ |
|
1117 This function opens the xsd file and generate a xml parser with class lookup from |
|
1118 the xml tree |
|
1119 """ |
1098 xsdfile = open(filepath, 'r') |
1120 xsdfile = open(filepath, 'r') |
1099 xsdstring = xsdfile.read() |
1121 xsdstring = xsdfile.read() |
1100 xsdfile.close() |
1122 xsdfile.close() |
1101 cwd = os.getcwd() |
1123 cwd = os.getcwd() |
1102 os.chdir(os.path.dirname(filepath)) |
1124 os.chdir(os.path.dirname(filepath)) |
1103 parser = GenerateParser(XSDClassFactory(minidom.parseString(xsdstring), filepath), xsdstring) |
1125 parser = GenerateParser(XSDClassFactory(minidom.parseString(xsdstring), filepath), xsdstring) |
1104 os.chdir(cwd) |
1126 os.chdir(cwd) |
1105 return parser |
1127 return parser |
1106 |
1128 |
1107 """ |
1129 |
1108 This function generate a xml from the xsd given as a string |
|
1109 """ |
|
1110 def GenerateParserFromXSDstring(xsdstring): |
1130 def GenerateParserFromXSDstring(xsdstring): |
|
1131 """ |
|
1132 This function generate a xml from the xsd given as a string |
|
1133 """ |
1111 return GenerateParser(XSDClassFactory(minidom.parseString(xsdstring)), xsdstring) |
1134 return GenerateParser(XSDClassFactory(minidom.parseString(xsdstring)), xsdstring) |
1112 |
1135 |
1113 |
1136 |
1114 #------------------------------------------------------------------------------- |
1137 # ------------------------------------------------------------------------------- |
1115 # XSD schema syntax elements |
1138 # XSD schema syntax elements |
1116 #------------------------------------------------------------------------------- |
1139 # ------------------------------------------------------------------------------- |
|
1140 |
1117 |
1141 |
1118 XSD_NAMESPACE = { |
1142 XSD_NAMESPACE = { |
1119 |
1143 |
1120 #------------------------------------------------------------------------------- |
1144 # ------------------------------------------------------------------------------- |
1121 # Syntax elements definition |
1145 # Syntax elements definition |
1122 #------------------------------------------------------------------------------- |
1146 # ------------------------------------------------------------------------------- |
1123 |
1147 |
1124 "all": {"struct": """ |
1148 "all": { |
|
1149 "struct": """ |
1125 <all |
1150 <all |
1126 id = ID |
1151 id = ID |
1127 maxOccurs = 1 : 1 |
1152 maxOccurs = 1 : 1 |
1128 minOccurs = (0 | 1) : 1 |
1153 minOccurs = (0 | 1) : 1 |
1129 {any attributes with non-schema namespace . . .}> |
1154 {any attributes with non-schema namespace . . .}> |
1130 Content: (annotation?, element*) |
1155 Content: (annotation?, element*) |
1131 </all>""", |
1156 </all>""", |
1132 "type": SYNTAXELEMENT, |
1157 "type": SYNTAXELEMENT, |
1133 "extract": { |
1158 "extract": { |
1134 "default": GenerateElement("all", ["id", "maxOccurs", "minOccurs"], |
1159 "default": GenerateElement( |
|
1160 "all", ["id", "maxOccurs", "minOccurs"], |
1135 re.compile("((?:annotation )?(?:element )*)")) |
1161 re.compile("((?:annotation )?(?:element )*)")) |
1136 }, |
1162 }, |
1137 "reduce": ReduceAll |
1163 "reduce": ReduceAll |
1138 }, |
1164 }, |
1139 |
1165 |
1140 "annotation": {"struct": """ |
1166 "annotation": { |
|
1167 "struct": """ |
1141 <annotation |
1168 <annotation |
1142 id = ID |
1169 id = ID |
1143 {any attributes with non-schema namespace . . .}> |
1170 {any attributes with non-schema namespace . . .}> |
1144 Content: (appinfo | documentation)* |
1171 Content: (appinfo | documentation)* |
1145 </annotation>""", |
1172 </annotation>""", |
1146 "type": SYNTAXELEMENT, |
1173 "type": SYNTAXELEMENT, |
1147 "extract": { |
1174 "extract": { |
1148 "default": GenerateElement("annotation", ["id"], |
1175 "default": GenerateElement( |
|
1176 "annotation", ["id"], |
1149 re.compile("((?:app_info |documentation )*)")) |
1177 re.compile("((?:app_info |documentation )*)")) |
1150 }, |
1178 }, |
1151 "reduce": ReduceAnnotation |
1179 "reduce": ReduceAnnotation |
1152 }, |
1180 }, |
1153 |
1181 |
1154 "any": {"struct": """ |
1182 "any": { |
|
1183 "struct": """ |
1155 <any |
1184 <any |
1156 id = ID |
1185 id = ID |
1157 maxOccurs = (nonNegativeInteger | unbounded) : 1 |
1186 maxOccurs = (nonNegativeInteger | unbounded) : 1 |
1158 minOccurs = nonNegativeInteger : 1 |
1187 minOccurs = nonNegativeInteger : 1 |
1159 namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any |
1188 namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any |
1160 processContents = (lax | skip | strict) : strict |
1189 processContents = (lax | skip | strict) : strict |
1161 {any attributes with non-schema namespace . . .}> |
1190 {any attributes with non-schema namespace . . .}> |
1162 Content: (annotation?) |
1191 Content: (annotation?) |
1163 </any>""", |
1192 </any>""", |
1164 "type": SYNTAXELEMENT, |
1193 "type": SYNTAXELEMENT, |
1165 "extract": { |
1194 "extract": { |
1166 "default": GenerateElement("any", |
1195 "default": GenerateElement( |
1167 ["id", "maxOccurs", "minOccurs", "namespace", "processContents"], |
1196 "any", |
|
1197 ["id", "maxOccurs", "minOccurs", "namespace", "processContents"], |
1168 re.compile("((?:annotation )?(?:simpleType )*)")) |
1198 re.compile("((?:annotation )?(?:simpleType )*)")) |
1169 }, |
1199 }, |
1170 "reduce": ReduceAny |
1200 "reduce": ReduceAny |
1171 }, |
1201 }, |
1172 |
1202 |
1173 "anyAttribute": {"struct": """ |
1203 "anyAttribute": { |
|
1204 "struct": """ |
1174 <anyAttribute |
1205 <anyAttribute |
1175 id = ID |
1206 id = ID |
1176 namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any |
1207 namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any |
1177 processContents = (lax | skip | strict) : strict |
1208 processContents = (lax | skip | strict) : strict |
1178 {any attributes with non-schema namespace . . .}> |
1209 {any attributes with non-schema namespace . . .}> |
1179 Content: (annotation?) |
1210 Content: (annotation?) |
1180 </anyAttribute>""", |
1211 </anyAttribute>""", |
1181 "type": SYNTAXELEMENT, |
1212 "type": SYNTAXELEMENT, |
1182 "extract": { |
1213 "extract": { |
1183 "default": GenerateElement("anyAttribute", |
1214 "default": GenerateElement( |
1184 ["id", "namespace", "processContents"], ONLY_ANNOTATION) |
1215 "anyAttribute", ["id", "namespace", "processContents"], ONLY_ANNOTATION) |
1185 }, |
1216 }, |
1186 "reduce": ReduceAnyAttribute |
1217 "reduce": ReduceAnyAttribute |
1187 }, |
1218 }, |
1188 |
1219 |
1189 "appinfo": {"struct": """ |
1220 "appinfo": { |
|
1221 "struct": """ |
1190 <appinfo |
1222 <appinfo |
1191 source = anyURI |
1223 source = anyURI |
1192 {any attributes with non-schema namespace . . .}> |
1224 {any attributes with non-schema namespace . . .}> |
1193 Content: ({any})* |
1225 Content: ({any})* |
1194 </appinfo>""", |
1226 </appinfo>""", |
1195 "type": SYNTAXELEMENT, |
1227 "type": SYNTAXELEMENT, |
1196 "extract": { |
1228 "extract": { |
1197 "default": GenerateElement("appinfo", ["source"], re.compile("(.*)"), True) |
1229 "default": GenerateElement("appinfo", ["source"], re.compile("(.*)"), True) |
1198 }, |
1230 }, |
1199 "reduce": ReduceAppInfo |
1231 "reduce": ReduceAppInfo |
1200 }, |
1232 }, |
1201 |
1233 |
1202 "attribute": {"struct": """ |
1234 "attribute": { |
|
1235 "struct": """ |
1203 <attribute |
1236 <attribute |
1204 default = string |
1237 default = string |
1205 fixed = string |
1238 fixed = string |
1206 form = (qualified | unqualified) |
1239 form = (qualified | unqualified) |
1207 id = ID |
1240 id = ID |
1210 type = QName |
1243 type = QName |
1211 use = (optional | prohibited | required) : optional |
1244 use = (optional | prohibited | required) : optional |
1212 {any attributes with non-schema namespace . . .}> |
1245 {any attributes with non-schema namespace . . .}> |
1213 Content: (annotation?, simpleType?) |
1246 Content: (annotation?, simpleType?) |
1214 </attribute>""", |
1247 </attribute>""", |
1215 "type": SYNTAXELEMENT, |
1248 "type": SYNTAXELEMENT, |
1216 "extract": { |
1249 "extract": { |
1217 "default": GenerateElement("attribute", |
1250 "default": GenerateElement( |
1218 ["default", "fixed", "form", "id", "name", "ref", "type", "use"], |
1251 "attribute", |
|
1252 ["default", "fixed", "form", "id", "name", "ref", "type", "use"], |
1219 re.compile("((?:annotation )?(?:simpleType )?)")), |
1253 re.compile("((?:annotation )?(?:simpleType )?)")), |
1220 "schema": GenerateElement("attribute", |
1254 "schema": GenerateElement( |
1221 ["default", "fixed", "form", "id", "name", "type"], |
1255 "attribute", |
|
1256 ["default", "fixed", "form", "id", "name", "type"], |
1222 re.compile("((?:annotation )?(?:simpleType )?)")) |
1257 re.compile("((?:annotation )?(?:simpleType )?)")) |
1223 }, |
1258 }, |
1224 "reduce": ReduceAttribute |
1259 "reduce": ReduceAttribute |
1225 }, |
1260 }, |
1226 |
1261 |
1227 "attributeGroup": {"struct": """ |
1262 "attributeGroup": { |
|
1263 "struct": """ |
1228 <attributeGroup |
1264 <attributeGroup |
1229 id = ID |
1265 id = ID |
1230 name = NCName |
1266 name = NCName |
1231 ref = QName |
1267 ref = QName |
1232 {any attributes with non-schema namespace . . .}> |
1268 {any attributes with non-schema namespace . . .}> |
1233 Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?)) |
1269 Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?)) |
1234 </attributeGroup>""", |
1270 </attributeGroup>""", |
1235 "type": SYNTAXELEMENT, |
1271 "type": SYNTAXELEMENT, |
1236 "extract": { |
1272 "extract": { |
1237 "default": GenerateElement("attributeGroup", |
1273 "default": GenerateElement( |
|
1274 "attributeGroup", |
1238 ["id", "ref"], ONLY_ANNOTATION), |
1275 ["id", "ref"], ONLY_ANNOTATION), |
1239 "schema": GenerateElement("attributeGroup", |
1276 "schema": GenerateElement( |
1240 ["id", "name"], |
1277 "attributeGroup", |
|
1278 ["id", "name"], |
1241 re.compile("((?:annotation )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")) |
1279 re.compile("((?:annotation )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")) |
1242 }, |
1280 }, |
1243 "reduce": ReduceAttributeGroup |
1281 "reduce": ReduceAttributeGroup |
1244 }, |
1282 }, |
1245 |
1283 |
1246 "choice": {"struct": """ |
1284 "choice": { |
|
1285 "struct": """ |
1247 <choice |
1286 <choice |
1248 id = ID |
1287 id = ID |
1249 maxOccurs = (nonNegativeInteger | unbounded) : 1 |
1288 maxOccurs = (nonNegativeInteger | unbounded) : 1 |
1250 minOccurs = nonNegativeInteger : 1 |
1289 minOccurs = nonNegativeInteger : 1 |
1251 {any attributes with non-schema namespace . . .}> |
1290 {any attributes with non-schema namespace . . .}> |
1252 Content: (annotation?, (element | group | choice | sequence | any)*) |
1291 Content: (annotation?, (element | group | choice | sequence | any)*) |
1253 </choice>""", |
1292 </choice>""", |
1254 "type": SYNTAXELEMENT, |
1293 "type": SYNTAXELEMENT, |
1255 "extract": { |
1294 "extract": { |
1256 "default": GenerateElement("choice", ["id", "maxOccurs", "minOccurs"], |
1295 "default": GenerateElement( |
|
1296 "choice", |
|
1297 ["id", "maxOccurs", "minOccurs"], |
1257 re.compile("((?:annotation )?(?:element |group |choice |sequence |any )*)")) |
1298 re.compile("((?:annotation )?(?:element |group |choice |sequence |any )*)")) |
1258 }, |
1299 }, |
1259 "reduce": ReduceChoice |
1300 "reduce": ReduceChoice |
1260 }, |
1301 }, |
1261 |
1302 |
1262 "complexContent": {"struct": """ |
1303 "complexContent": { |
|
1304 "struct": """ |
1263 <complexContent |
1305 <complexContent |
1264 id = ID |
1306 id = ID |
1265 mixed = boolean |
1307 mixed = boolean |
1266 {any attributes with non-schema namespace . . .}> |
1308 {any attributes with non-schema namespace . . .}> |
1267 Content: (annotation?, (restriction | extension)) |
1309 Content: (annotation?, (restriction | extension)) |
1268 </complexContent>""", |
1310 </complexContent>""", |
1269 "type": SYNTAXELEMENT, |
1311 "type": SYNTAXELEMENT, |
1270 "extract": { |
1312 "extract": { |
1271 "default": GenerateElement("complexContent", ["id", "mixed"], |
1313 "default": GenerateElement( |
|
1314 "complexContent", |
|
1315 ["id", "mixed"], |
1272 re.compile("((?:annotation )?(?:restriction |extension ))")) |
1316 re.compile("((?:annotation )?(?:restriction |extension ))")) |
1273 }, |
1317 }, |
1274 "reduce": ReduceComplexContent |
1318 "reduce": ReduceComplexContent |
1275 }, |
1319 }, |
1276 |
1320 |
1277 "complexType": {"struct": """ |
1321 "complexType": { |
|
1322 "struct": """ |
1278 <complexType |
1323 <complexType |
1279 abstract = boolean : false |
1324 abstract = boolean : false |
1280 block = (#all | List of (extension | restriction)) |
1325 block = (#all | List of (extension | restriction)) |
1281 final = (#all | List of (extension | restriction)) |
1326 final = (#all | List of (extension | restriction)) |
1282 id = ID |
1327 id = ID |
1283 mixed = boolean : false |
1328 mixed = boolean : false |
1284 name = NCName |
1329 name = NCName |
1285 {any attributes with non-schema namespace . . .}> |
1330 {any attributes with non-schema namespace . . .}> |
1286 Content: (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))) |
1331 Content: (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))) |
1287 </complexType>""", |
1332 </complexType>""", |
1288 "type": SYNTAXELEMENT, |
1333 "type": SYNTAXELEMENT, |
1289 "extract": { |
1334 "extract": { |
1290 "default": GenerateElement("complexType", |
1335 "default": GenerateElement( |
1291 ["abstract", "block", "final", "id", "mixed", "name"], |
1336 "complexType", |
|
1337 ["abstract", "block", "final", "id", "mixed", "name"], |
1292 re.compile("((?:annotation )?(?:simpleContent |complexContent |(?:(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))))")) |
1338 re.compile("((?:annotation )?(?:simpleContent |complexContent |(?:(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))))")) |
1293 }, |
1339 }, |
1294 "reduce": ReduceComplexType |
1340 "reduce": ReduceComplexType |
1295 }, |
1341 }, |
1296 |
1342 |
1297 "documentation": {"struct" : """ |
1343 "documentation": { |
|
1344 "struct": """ |
1298 <documentation |
1345 <documentation |
1299 source = anyURI |
1346 source = anyURI |
1300 xml:lang = language |
1347 xml:lang = language |
1301 {any attributes with non-schema namespace . . .}> |
1348 {any attributes with non-schema namespace . . .}> |
1302 Content: ({any})* |
1349 Content: ({any})* |
1303 </documentation>""", |
1350 </documentation>""", |
1304 "type": SYNTAXELEMENT, |
1351 "type": SYNTAXELEMENT, |
1305 "extract": { |
1352 "extract": { |
1306 "default": GenerateElement("documentation", |
1353 "default": GenerateElement( |
1307 ["source", "lang"], re.compile("(.*)"), True) |
1354 "documentation", |
|
1355 ["source", "lang"], |
|
1356 re.compile("(.*)"), True) |
1308 }, |
1357 }, |
1309 "reduce": ReduceDocumentation |
1358 "reduce": ReduceDocumentation |
1310 }, |
1359 }, |
1311 |
1360 |
1312 "element": {"struct": """ |
1361 "element": { |
|
1362 "struct": """ |
1313 <element |
1363 <element |
1314 abstract = boolean : false |
1364 abstract = boolean : false |
1315 block = (#all | List of (extension | restriction | substitution)) |
1365 block = (#all | List of (extension | restriction | substitution)) |
1316 default = string |
1366 default = string |
1317 final = (#all | List of (extension | restriction)) |
1367 final = (#all | List of (extension | restriction)) |
1326 substitutionGroup = QName |
1376 substitutionGroup = QName |
1327 type = QName |
1377 type = QName |
1328 {any attributes with non-schema namespace . . .}> |
1378 {any attributes with non-schema namespace . . .}> |
1329 Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*)) |
1379 Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*)) |
1330 </element>""", |
1380 </element>""", |
1331 "type": SYNTAXELEMENT, |
1381 "type": SYNTAXELEMENT, |
1332 "extract": { |
1382 "extract": { |
1333 "default": GenerateElement("element", |
1383 "default": GenerateElement( |
1334 ["abstract", "block", "default", "final", "fixed", "form", "id", "maxOccurs", "minOccurs", "name", "nillable", "ref", "substitutionGroup", "type"], |
1384 "element", |
|
1385 ["abstract", "block", "default", "final", "fixed", "form", "id", "maxOccurs", "minOccurs", "name", "nillable", "ref", "substitutionGroup", "type"], |
1335 re.compile("((?:annotation )?(?:simpleType |complexType )?(?:unique |key |keyref )*)")), |
1386 re.compile("((?:annotation )?(?:simpleType |complexType )?(?:unique |key |keyref )*)")), |
1336 "schema": GenerateElement("element", |
1387 "schema": GenerateElement( |
1337 ["abstract", "block", "default", "final", "fixed", "form", "id", "name", "nillable", "substitutionGroup", "type"], |
1388 "element", |
|
1389 ["abstract", "block", "default", "final", "fixed", "form", "id", "name", "nillable", "substitutionGroup", "type"], |
1338 re.compile("((?:annotation )?(?:simpleType |complexType )?(?:unique |key |keyref )*)")) |
1390 re.compile("((?:annotation )?(?:simpleType |complexType )?(?:unique |key |keyref )*)")) |
1339 }, |
1391 }, |
1340 "reduce": ReduceElement |
1392 "reduce": ReduceElement |
1341 }, |
1393 }, |
1342 |
1394 |
1343 "enumeration": {"struct": """ |
1395 "enumeration": { |
|
1396 "struct": """ |
1344 <enumeration |
1397 <enumeration |
1345 id = ID |
1398 id = ID |
1346 value = anySimpleType |
1399 value = anySimpleType |
1347 {any attributes with non-schema namespace . . .}> |
1400 {any attributes with non-schema namespace . . .}> |
1348 Content: (annotation?) |
1401 Content: (annotation?) |
1349 </enumeration>""", |
1402 </enumeration>""", |
1350 "type": SYNTAXELEMENT, |
1403 "type": SYNTAXELEMENT, |
1351 "extract": { |
1404 "extract": { |
1352 "default": GenerateElement("enumeration", ["id", "value"], ONLY_ANNOTATION) |
1405 "default": GenerateElement("enumeration", ["id", "value"], ONLY_ANNOTATION) |
1353 }, |
1406 }, |
1354 "reduce": GenerateFacetReducing("enumeration", False) |
1407 "reduce": GenerateFacetReducing("enumeration", False) |
1355 }, |
1408 }, |
1356 |
1409 |
1357 "extension": {"struct": """ |
1410 "extension": { |
|
1411 "struct": """ |
1358 <extension |
1412 <extension |
1359 base = QName |
1413 base = QName |
1360 id = ID |
1414 id = ID |
1361 {any attributes with non-schema namespace . . .}> |
1415 {any attributes with non-schema namespace . . .}> |
1362 Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))) |
1416 Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))) |
1363 </extension>""", |
1417 </extension>""", |
1364 "type": SYNTAXELEMENT, |
1418 "type": SYNTAXELEMENT, |
1365 "extract": { |
1419 "extract": { |
1366 "default": GenerateElement("extension", ["base", "id"], |
1420 "default": GenerateElement( |
|
1421 "extension", |
|
1422 ["base", "id"], |
1367 re.compile("((?:annotation )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")), |
1423 re.compile("((?:annotation )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")), |
1368 "complexContent": GenerateElement("extension", ["base", "id"], |
1424 "complexContent": GenerateElement( |
|
1425 "extension", |
|
1426 ["base", "id"], |
1369 re.compile("((?:annotation )?(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")) |
1427 re.compile("((?:annotation )?(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")) |
1370 }, |
1428 }, |
1371 "reduce": ReduceExtension |
1429 "reduce": ReduceExtension |
1372 }, |
1430 }, |
1373 |
1431 |
1374 "field": {"struct": """ |
1432 "field": { |
|
1433 "struct": """ |
1375 <field |
1434 <field |
1376 id = ID |
1435 id = ID |
1377 xpath = a subset of XPath expression, see below |
1436 xpath = a subset of XPath expression, see below |
1378 {any attributes with non-schema namespace . . .}> |
1437 {any attributes with non-schema namespace . . .}> |
1379 Content: (annotation?) |
1438 Content: (annotation?) |
1380 </field>""", |
1439 </field>""", |
1381 "type": SYNTAXELEMENT, |
1440 "type": SYNTAXELEMENT, |
1382 "extract": { |
1441 "extract": { |
1383 "default": GenerateElement("field", ["id", "xpath"], ONLY_ANNOTATION) |
1442 "default": GenerateElement("field", ["id", "xpath"], ONLY_ANNOTATION) |
1384 }, |
1443 }, |
1385 "reduce": ReduceField |
1444 "reduce": ReduceField |
1386 }, |
1445 }, |
1387 |
1446 |
1388 "fractionDigits": {"struct": """ |
1447 "fractionDigits": { |
|
1448 "struct": """ |
1389 <fractionDigits |
1449 <fractionDigits |
1390 fixed = boolean : false |
1450 fixed = boolean : false |
1391 id = ID |
1451 id = ID |
1392 value = nonNegativeInteger |
1452 value = nonNegativeInteger |
1393 {any attributes with non-schema namespace . . .}> |
1453 {any attributes with non-schema namespace . . .}> |
1394 Content: (annotation?) |
1454 Content: (annotation?) |
1395 </fractionDigits>""", |
1455 </fractionDigits>""", |
1396 "type": SYNTAXELEMENT, |
1456 "type": SYNTAXELEMENT, |
1397 "extract": { |
1457 "extract": { |
1398 "default": GenerateElement("fractionDigits", |
1458 "default": GenerateElement( |
1399 ["fixed", "id", "value"], ONLY_ANNOTATION) |
1459 "fractionDigits", |
|
1460 ["fixed", "id", "value"], |
|
1461 ONLY_ANNOTATION) |
1400 }, |
1462 }, |
1401 "reduce": GenerateFacetReducing("fractionDigits", True) |
1463 "reduce": GenerateFacetReducing("fractionDigits", True) |
1402 }, |
1464 }, |
1403 |
1465 |
1404 "group": {"struct": """ |
1466 "group": { |
|
1467 "struct": """ |
1405 <group |
1468 <group |
1406 id = ID |
1469 id = ID |
1407 maxOccurs = (nonNegativeInteger | unbounded) : 1 |
1470 maxOccurs = (nonNegativeInteger | unbounded) : 1 |
1408 minOccurs = nonNegativeInteger : 1 |
1471 minOccurs = nonNegativeInteger : 1 |
1409 name = NCName |
1472 name = NCName |
1410 ref = QName |
1473 ref = QName |
1411 {any attributes with non-schema namespace . . .}> |
1474 {any attributes with non-schema namespace . . .}> |
1412 Content: (annotation?, (all | choice | sequence)?) |
1475 Content: (annotation?, (all | choice | sequence)?) |
1413 </group>""", |
1476 </group>""", |
1414 "type": SYNTAXELEMENT, |
1477 "type": SYNTAXELEMENT, |
1415 "extract": { |
1478 "extract": { |
1416 "default": GenerateElement("group", |
1479 "default": GenerateElement( |
1417 ["id", "maxOccurs", "minOccurs", "ref"], |
1480 "group", |
|
1481 ["id", "maxOccurs", "minOccurs", "ref"], |
1418 re.compile("((?:annotation )?(?:all |choice |sequence )?)")), |
1482 re.compile("((?:annotation )?(?:all |choice |sequence )?)")), |
1419 "schema": GenerateElement("group", |
1483 "schema": GenerateElement( |
1420 ["id", "name"], |
1484 "group", |
|
1485 ["id", "name"], |
1421 re.compile("((?:annotation )?(?:all |choice |sequence )?)")) |
1486 re.compile("((?:annotation )?(?:all |choice |sequence )?)")) |
1422 }, |
1487 }, |
1423 "reduce": ReduceGroup |
1488 "reduce": ReduceGroup |
1424 }, |
1489 }, |
1425 |
1490 |
1426 "import": {"struct": """ |
1491 "import": { |
|
1492 "struct": """ |
1427 <import |
1493 <import |
1428 id = ID |
1494 id = ID |
1429 namespace = anyURI |
1495 namespace = anyURI |
1430 schemaLocation = anyURI |
1496 schemaLocation = anyURI |
1431 {any attributes with non-schema namespace . . .}> |
1497 {any attributes with non-schema namespace . . .}> |
1432 Content: (annotation?) |
1498 Content: (annotation?) |
1433 </import>""", |
1499 </import>""", |
1434 "type": SYNTAXELEMENT, |
1500 "type": SYNTAXELEMENT, |
1435 "extract": { |
1501 "extract": { |
1436 "default": GenerateElement("import", |
1502 "default": GenerateElement( |
1437 ["id", "namespace", "schemaLocation"], ONLY_ANNOTATION) |
1503 "import", |
|
1504 ["id", "namespace", "schemaLocation"], |
|
1505 ONLY_ANNOTATION) |
1438 }, |
1506 }, |
1439 "reduce": ReduceImport |
1507 "reduce": ReduceImport |
1440 }, |
1508 }, |
1441 |
1509 |
1442 "include": {"struct": """ |
1510 "include": { |
|
1511 "struct": """ |
1443 <include |
1512 <include |
1444 id = ID |
1513 id = ID |
1445 schemaLocation = anyURI |
1514 schemaLocation = anyURI |
1446 {any attributes with non-schema namespace . . .}> |
1515 {any attributes with non-schema namespace . . .}> |
1447 Content: (annotation?) |
1516 Content: (annotation?) |
1448 </include>""", |
1517 </include>""", |
1449 "type": SYNTAXELEMENT, |
1518 "type": SYNTAXELEMENT, |
1450 "extract": { |
1519 "extract": { |
1451 "default": GenerateElement("include", |
1520 "default": GenerateElement( |
1452 ["id", "schemaLocation"], ONLY_ANNOTATION) |
1521 "include", |
|
1522 ["id", "schemaLocation"], |
|
1523 ONLY_ANNOTATION) |
1453 }, |
1524 }, |
1454 "reduce": ReduceInclude |
1525 "reduce": ReduceInclude |
1455 }, |
1526 }, |
1456 |
1527 |
1457 "key": {"struct": """ |
1528 "key": { |
|
1529 "struct": """ |
1458 <key |
1530 <key |
1459 id = ID |
1531 id = ID |
1460 name = NCName |
1532 name = NCName |
1461 {any attributes with non-schema namespace . . .}> |
1533 {any attributes with non-schema namespace . . .}> |
1462 Content: (annotation?, (selector, field+)) |
1534 Content: (annotation?, (selector, field+)) |
1463 </key>""", |
1535 </key>""", |
1464 "type": SYNTAXELEMENT, |
1536 "type": SYNTAXELEMENT, |
1465 "extract": { |
1537 "extract": { |
1466 "default": GenerateElement("key", ["id", "name"], |
1538 "default": GenerateElement( |
|
1539 "key", ["id", "name"], |
1467 re.compile("((?:annotation )?(?:selector (?:field )+))")) |
1540 re.compile("((?:annotation )?(?:selector (?:field )+))")) |
1468 }, |
1541 }, |
1469 "reduce": ReduceKey |
1542 "reduce": ReduceKey |
1470 }, |
1543 }, |
1471 |
1544 |
1472 "keyref": {"struct": """ |
1545 "keyref": { |
|
1546 "struct": """ |
1473 <keyref |
1547 <keyref |
1474 id = ID |
1548 id = ID |
1475 name = NCName |
1549 name = NCName |
1476 refer = QName |
1550 refer = QName |
1477 {any attributes with non-schema namespace . . .}> |
1551 {any attributes with non-schema namespace . . .}> |
1478 Content: (annotation?, (selector, field+)) |
1552 Content: (annotation?, (selector, field+)) |
1479 </keyref>""", |
1553 </keyref>""", |
1480 "type": SYNTAXELEMENT, |
1554 "type": SYNTAXELEMENT, |
1481 "extract": { |
1555 "extract": { |
1482 "default": GenerateElement("keyref", ["id", "name", "refer"], |
1556 "default": GenerateElement( |
|
1557 "keyref", ["id", "name", "refer"], |
1483 re.compile("((?:annotation )?(?:selector (?:field )+))")) |
1558 re.compile("((?:annotation )?(?:selector (?:field )+))")) |
1484 }, |
1559 }, |
1485 "reduce": ReduceKeyRef |
1560 "reduce": ReduceKeyRef |
1486 }, |
1561 }, |
1487 |
1562 |
1488 "length": {"struct" : """ |
1563 "length": { |
|
1564 "struct": """ |
1489 <length |
1565 <length |
1490 fixed = boolean : false |
1566 fixed = boolean : false |
1491 id = ID |
1567 id = ID |
1492 value = nonNegativeInteger |
1568 value = nonNegativeInteger |
1493 {any attributes with non-schema namespace . . .}> |
1569 {any attributes with non-schema namespace . . .}> |
1494 Content: (annotation?) |
1570 Content: (annotation?) |
1495 </length>""", |
1571 </length>""", |
1496 "type": SYNTAXELEMENT, |
1572 "type": SYNTAXELEMENT, |
1497 "extract": { |
1573 "extract": { |
1498 "default": GenerateElement("length", |
1574 "default": GenerateElement( |
1499 ["fixed", "id", "value"], ONLY_ANNOTATION) |
1575 "length", ["fixed", "id", "value"], ONLY_ANNOTATION) |
1500 }, |
1576 }, |
1501 "reduce": GenerateFacetReducing("length", True) |
1577 "reduce": GenerateFacetReducing("length", True) |
1502 }, |
1578 }, |
1503 |
1579 |
1504 "list": {"struct": """ |
1580 "list": { |
|
1581 "struct": """ |
1505 <list |
1582 <list |
1506 id = ID |
1583 id = ID |
1507 itemType = QName |
1584 itemType = QName |
1508 {any attributes with non-schema namespace . . .}> |
1585 {any attributes with non-schema namespace . . .}> |
1509 Content: (annotation?, simpleType?) |
1586 Content: (annotation?, simpleType?) |
1510 </list>""", |
1587 </list>""", |
1511 "type": SYNTAXELEMENT, |
1588 "type": SYNTAXELEMENT, |
1512 "extract": { |
1589 "extract": { |
1513 "default": GenerateElement("list", ["id", "itemType"], |
1590 "default": GenerateElement( |
|
1591 "list", ["id", "itemType"], |
1514 re.compile("((?:annotation )?(?:simpleType )?)$")) |
1592 re.compile("((?:annotation )?(?:simpleType )?)$")) |
1515 }, |
1593 }, |
1516 "reduce": ReduceList |
1594 "reduce": ReduceList |
1517 }, |
1595 }, |
1518 |
1596 |
1519 "maxExclusive": {"struct": """ |
1597 "maxExclusive": { |
|
1598 "struct": """ |
1520 <maxInclusive |
1599 <maxInclusive |
1521 fixed = boolean : false |
1600 fixed = boolean : false |
1522 id = ID |
1601 id = ID |
1523 value = anySimpleType |
1602 value = anySimpleType |
1524 {any attributes with non-schema namespace . . .}> |
1603 {any attributes with non-schema namespace . . .}> |
1525 Content: (annotation?) |
1604 Content: (annotation?) |
1526 </maxInclusive>""", |
1605 </maxInclusive>""", |
1527 "type": SYNTAXELEMENT, |
1606 "type": SYNTAXELEMENT, |
1528 "extract": { |
1607 "extract": { |
1529 "default": GenerateElement("maxExclusive", |
1608 "default": GenerateElement( |
1530 ["fixed", "id", "value"], ONLY_ANNOTATION) |
1609 "maxExclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) |
1531 }, |
1610 }, |
1532 "reduce": GenerateFacetReducing("maxExclusive", True) |
1611 "reduce": GenerateFacetReducing("maxExclusive", True) |
1533 }, |
1612 }, |
1534 |
1613 |
1535 "maxInclusive": {"struct": """ |
1614 "maxInclusive": { |
|
1615 "struct": """ |
1536 <maxExclusive |
1616 <maxExclusive |
1537 fixed = boolean : false |
1617 fixed = boolean : false |
1538 id = ID |
1618 id = ID |
1539 value = anySimpleType |
1619 value = anySimpleType |
1540 {any attributes with non-schema namespace . . .}> |
1620 {any attributes with non-schema namespace . . .}> |
1541 Content: (annotation?) |
1621 Content: (annotation?) |
1542 </maxExclusive>""", |
1622 </maxExclusive>""", |
1543 "type": SYNTAXELEMENT, |
1623 "type": SYNTAXELEMENT, |
1544 "extract": { |
1624 "extract": { |
1545 "default": GenerateElement("maxInclusive", |
1625 "default": GenerateElement( |
1546 ["fixed", "id", "value"], ONLY_ANNOTATION) |
1626 "maxInclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) |
1547 }, |
1627 }, |
1548 "reduce": GenerateFacetReducing("maxInclusive", True) |
1628 "reduce": GenerateFacetReducing("maxInclusive", True) |
1549 }, |
1629 }, |
1550 |
1630 |
1551 "maxLength": {"struct": """ |
1631 "maxLength": { |
|
1632 "struct": """ |
1552 <maxLength |
1633 <maxLength |
1553 fixed = boolean : false |
1634 fixed = boolean : false |
1554 id = ID |
1635 id = ID |
1555 value = nonNegativeInteger |
1636 value = nonNegativeInteger |
1556 {any attributes with non-schema namespace . . .}> |
1637 {any attributes with non-schema namespace . . .}> |
1557 Content: (annotation?) |
1638 Content: (annotation?) |
1558 </maxLength>""", |
1639 </maxLength>""", |
1559 "type": SYNTAXELEMENT, |
1640 "type": SYNTAXELEMENT, |
1560 "extract": { |
1641 "extract": { |
1561 "default": GenerateElement("maxLength", |
1642 "default": GenerateElement( |
1562 ["fixed", "id", "value"], ONLY_ANNOTATION) |
1643 "maxLength", ["fixed", "id", "value"], ONLY_ANNOTATION) |
1563 }, |
1644 }, |
1564 "reduce": GenerateFacetReducing("maxLength", True) |
1645 "reduce": GenerateFacetReducing("maxLength", True) |
1565 }, |
1646 }, |
1566 |
1647 |
1567 "minExclusive": {"struct": """ |
1648 "minExclusive": { |
|
1649 "struct": """ |
1568 <minExclusive |
1650 <minExclusive |
1569 fixed = boolean : false |
1651 fixed = boolean : false |
1570 id = ID |
1652 id = ID |
1571 value = anySimpleType |
1653 value = anySimpleType |
1572 {any attributes with non-schema namespace . . .}> |
1654 {any attributes with non-schema namespace . . .}> |
1573 Content: (annotation?) |
1655 Content: (annotation?) |
1574 </minExclusive>""", |
1656 </minExclusive>""", |
1575 "type": SYNTAXELEMENT, |
1657 "type": SYNTAXELEMENT, |
1576 "extract": { |
1658 "extract": { |
1577 "default": GenerateElement("minExclusive", |
1659 "default": GenerateElement( |
1578 ["fixed", "id", "value"], ONLY_ANNOTATION) |
1660 "minExclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) |
1579 }, |
1661 }, |
1580 "reduce": GenerateFacetReducing("minExclusive", True) |
1662 "reduce": GenerateFacetReducing("minExclusive", True) |
1581 }, |
1663 }, |
1582 |
1664 |
1583 "minInclusive": {"struct": """ |
1665 "minInclusive": { |
|
1666 "struct": """ |
1584 <minInclusive |
1667 <minInclusive |
1585 fixed = boolean : false |
1668 fixed = boolean : false |
1586 id = ID |
1669 id = ID |
1587 value = anySimpleType |
1670 value = anySimpleType |
1588 {any attributes with non-schema namespace . . .}> |
1671 {any attributes with non-schema namespace . . .}> |
1589 Content: (annotation?) |
1672 Content: (annotation?) |
1590 </minInclusive>""", |
1673 </minInclusive>""", |
1591 "type": SYNTAXELEMENT, |
1674 "type": SYNTAXELEMENT, |
1592 "extract": { |
1675 "extract": { |
1593 "default": GenerateElement("minInclusive", |
1676 "default": GenerateElement( |
1594 ["fixed", "id", "value"], ONLY_ANNOTATION) |
1677 "minInclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) |
1595 }, |
1678 }, |
1596 "reduce": GenerateFacetReducing("minInclusive", True) |
1679 "reduce": GenerateFacetReducing("minInclusive", True) |
1597 }, |
1680 }, |
1598 |
1681 |
1599 "minLength": {"struct": """ |
1682 "minLength": { |
|
1683 "struct": """ |
1600 <minLength |
1684 <minLength |
1601 fixed = boolean : false |
1685 fixed = boolean : false |
1602 id = ID |
1686 id = ID |
1603 value = nonNegativeInteger |
1687 value = nonNegativeInteger |
1604 {any attributes with non-schema namespace . . .}> |
1688 {any attributes with non-schema namespace . . .}> |
1605 Content: (annotation?) |
1689 Content: (annotation?) |
1606 </minLength>""", |
1690 </minLength>""", |
1607 "type": SYNTAXELEMENT, |
1691 "type": SYNTAXELEMENT, |
1608 "extract": { |
1692 "extract": { |
1609 "default": GenerateElement("minLength", |
1693 "default": GenerateElement( |
1610 ["fixed", "id", "value"], ONLY_ANNOTATION) |
1694 "minLength", ["fixed", "id", "value"], ONLY_ANNOTATION) |
1611 }, |
1695 }, |
1612 "reduce": GenerateFacetReducing("minLength", True) |
1696 "reduce": GenerateFacetReducing("minLength", True) |
1613 }, |
1697 }, |
1614 |
1698 |
1615 "pattern": {"struct": """ |
1699 "pattern": { |
|
1700 "struct": """ |
1616 <pattern |
1701 <pattern |
1617 id = ID |
1702 id = ID |
1618 value = string |
1703 value = string |
1619 {any attributes with non-schema namespace . . .}> |
1704 {any attributes with non-schema namespace . . .}> |
1620 Content: (annotation?) |
1705 Content: (annotation?) |
1621 </pattern>""", |
1706 </pattern>""", |
1622 "type": SYNTAXELEMENT, |
1707 "type": SYNTAXELEMENT, |
1623 "extract": { |
1708 "extract": { |
1624 "default": GenerateElement("pattern", ["id", "value"], ONLY_ANNOTATION) |
1709 "default": GenerateElement("pattern", ["id", "value"], ONLY_ANNOTATION) |
1625 }, |
1710 }, |
1626 "reduce": GenerateFacetReducing("pattern", False) |
1711 "reduce": GenerateFacetReducing("pattern", False) |
1627 }, |
1712 }, |
1628 |
1713 |
1629 "redefine": {"struct": """ |
1714 "redefine": { |
|
1715 "struct": """ |
1630 <redefine |
1716 <redefine |
1631 id = ID |
1717 id = ID |
1632 schemaLocation = anyURI |
1718 schemaLocation = anyURI |
1633 {any attributes with non-schema namespace . . .}> |
1719 {any attributes with non-schema namespace . . .}> |
1634 Content: (annotation | (simpleType | complexType | group | attributeGroup))* |
1720 Content: (annotation | (simpleType | complexType | group | attributeGroup))* |
1635 </redefine>""", |
1721 </redefine>""", |
1636 "type": SYNTAXELEMENT, |
1722 "type": SYNTAXELEMENT, |
1637 "extract": { |
1723 "extract": { |
1638 "default": GenerateElement("refine", ["id", "schemaLocation"], |
1724 "default": GenerateElement( |
|
1725 "refine", ["id", "schemaLocation"], |
1639 re.compile("((?:annotation |(?:simpleType |complexType |group |attributeGroup ))*)")) |
1726 re.compile("((?:annotation |(?:simpleType |complexType |group |attributeGroup ))*)")) |
1640 }, |
1727 }, |
1641 "reduce": ReduceRedefine |
1728 "reduce": ReduceRedefine |
1642 }, |
1729 }, |
1643 |
1730 |
1644 "restriction": {"struct": """ |
1731 "restriction": { |
|
1732 "struct": """ |
1645 <restriction |
1733 <restriction |
1646 base = QName |
1734 base = QName |
1647 id = ID |
1735 id = ID |
1648 {any attributes with non-schema namespace . . .}> |
1736 {any attributes with non-schema namespace . . .}> |
1649 Content: (annotation?, (group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)) |
1737 Content: (annotation?, (group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)) |
1650 </restriction>""", |
1738 </restriction>""", |
1651 "type": SYNTAXELEMENT, |
1739 "type": SYNTAXELEMENT, |
1652 "extract": { |
1740 "extract": { |
1653 "default": GenerateElement("restriction", ["base", "id"], |
1741 "default": GenerateElement( |
|
1742 "restriction", |
|
1743 ["base", "id"], |
1654 re.compile("((?:annotation )?(?:(?:simpleType )?(?:(?:minExclusive |minInclusive |maxExclusive |maxInclusive |totalDigits |fractionDigits |length |minLength |maxLength |enumeration |whiteSpace |pattern )*)))")), |
1744 re.compile("((?:annotation )?(?:(?:simpleType )?(?:(?:minExclusive |minInclusive |maxExclusive |maxInclusive |totalDigits |fractionDigits |length |minLength |maxLength |enumeration |whiteSpace |pattern )*)))")), |
1655 "simpleContent": GenerateElement("restriction", ["base", "id"], |
1745 "simpleContent": GenerateElement( |
|
1746 "restriction", |
|
1747 ["base", "id"], |
1656 re.compile("((?:annotation )?(?:(?:simpleType )?(?:(?:minExclusive |minInclusive |maxExclusive |maxInclusive |totalDigits |fractionDigits |length |minLength |maxLength |enumeration |whiteSpace |pattern )*)?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?)))")), |
1748 re.compile("((?:annotation )?(?:(?:simpleType )?(?:(?:minExclusive |minInclusive |maxExclusive |maxInclusive |totalDigits |fractionDigits |length |minLength |maxLength |enumeration |whiteSpace |pattern )*)?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?)))")), |
1657 "complexContent": GenerateElement("restriction", ["base", "id"], |
1749 "complexContent": GenerateElement( |
|
1750 "restriction", |
|
1751 ["base", "id"], |
1658 re.compile("((?:annotation )?(?:(?:simpleType )?(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?)))")), |
1752 re.compile("((?:annotation )?(?:(?:simpleType )?(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?)))")), |
1659 }, |
1753 }, |
1660 "reduce": ReduceRestriction |
1754 "reduce": ReduceRestriction |
1661 }, |
1755 }, |
1662 |
1756 |
1663 "schema": {"struct": """ |
1757 "schema": { |
|
1758 "struct": """ |
1664 <schema |
1759 <schema |
1665 attributeFormDefault = (qualified | unqualified) : unqualified |
1760 attributeFormDefault = (qualified | unqualified) : unqualified |
1666 blockDefault = (#all | List of (extension | restriction | substitution)) : '' |
1761 blockDefault = (#all | List of (extension | restriction | substitution)) : '' |
1667 elementFormDefault = (qualified | unqualified) : unqualified |
1762 elementFormDefault = (qualified | unqualified) : unqualified |
1668 finalDefault = (#all | List of (extension | restriction | list | union)) : '' |
1763 finalDefault = (#all | List of (extension | restriction | list | union)) : '' |
1671 version = token |
1766 version = token |
1672 xml:lang = language |
1767 xml:lang = language |
1673 {any attributes with non-schema namespace . . .}> |
1768 {any attributes with non-schema namespace . . .}> |
1674 Content: ((include | import | redefine | annotation)*, (((simpleType | complexType | group | attributeGroup) | element | attribute | notation), annotation*)*) |
1769 Content: ((include | import | redefine | annotation)*, (((simpleType | complexType | group | attributeGroup) | element | attribute | notation), annotation*)*) |
1675 </schema>""", |
1770 </schema>""", |
1676 "type": SYNTAXELEMENT, |
1771 "type": SYNTAXELEMENT, |
1677 "extract": { |
1772 "extract": { |
1678 "default": GenerateElement("schema", |
1773 "default": GenerateElement( |
1679 ["attributeFormDefault", "blockDefault", "elementFormDefault", "finalDefault", "id", "targetNamespace", "version", "lang"], |
1774 "schema", |
|
1775 ["attributeFormDefault", |
|
1776 "blockDefault", |
|
1777 "elementFormDefault", |
|
1778 "finalDefault", |
|
1779 "id", |
|
1780 "targetNamespace", |
|
1781 "version", |
|
1782 "lang"], |
1680 re.compile("((?:include |import |redefine |annotation )*(?:(?:(?:simpleType |complexType |group |attributeGroup )|element |attribute |annotation )(?:annotation )*)*)")) |
1783 re.compile("((?:include |import |redefine |annotation )*(?:(?:(?:simpleType |complexType |group |attributeGroup )|element |attribute |annotation )(?:annotation )*)*)")) |
1681 } |
1784 } |
1682 }, |
1785 }, |
1683 |
1786 |
1684 "selector": {"struct": """ |
1787 "selector": { |
|
1788 "struct": """ |
1685 <selector |
1789 <selector |
1686 id = ID |
1790 id = ID |
1687 xpath = a subset of XPath expression, see below |
1791 xpath = a subset of XPath expression, see below |
1688 {any attributes with non-schema namespace . . .}> |
1792 {any attributes with non-schema namespace . . .}> |
1689 Content: (annotation?) |
1793 Content: (annotation?) |
1690 </selector>""", |
1794 </selector>""", |
1691 "type": SYNTAXELEMENT, |
1795 "type": SYNTAXELEMENT, |
1692 "extract": { |
1796 "extract": { |
1693 "default": GenerateElement("selector", ["id", "xpath"], ONLY_ANNOTATION) |
1797 "default": GenerateElement("selector", ["id", "xpath"], ONLY_ANNOTATION) |
1694 }, |
1798 }, |
1695 "reduce": ReduceSelector |
1799 "reduce": ReduceSelector |
1696 }, |
1800 }, |
1697 |
1801 |
1698 "sequence": {"struct": """ |
1802 "sequence": { |
|
1803 "struct": """ |
1699 <sequence |
1804 <sequence |
1700 id = ID |
1805 id = ID |
1701 maxOccurs = (nonNegativeInteger | unbounded) : 1 |
1806 maxOccurs = (nonNegativeInteger | unbounded) : 1 |
1702 minOccurs = nonNegativeInteger : 1 |
1807 minOccurs = nonNegativeInteger : 1 |
1703 {any attributes with non-schema namespace . . .}> |
1808 {any attributes with non-schema namespace . . .}> |
1704 Content: (annotation?, (element | group | choice | sequence | any)*) |
1809 Content: (annotation?, (element | group | choice | sequence | any)*) |
1705 </sequence>""", |
1810 </sequence>""", |
1706 "type": SYNTAXELEMENT, |
1811 "type": SYNTAXELEMENT, |
1707 "extract": { |
1812 "extract": { |
1708 "default": GenerateElement("sequence", ["id", "maxOccurs", "minOccurs"], |
1813 "default": GenerateElement( |
|
1814 "sequence", ["id", "maxOccurs", "minOccurs"], |
1709 re.compile("((?:annotation )?(?:element |group |choice |sequence |any )*)")) |
1815 re.compile("((?:annotation )?(?:element |group |choice |sequence |any )*)")) |
1710 }, |
1816 }, |
1711 "reduce": ReduceSequence |
1817 "reduce": ReduceSequence |
1712 }, |
1818 }, |
1713 |
1819 |
1714 "simpleContent": {"struct" : """ |
1820 "simpleContent": { |
|
1821 "struct": """ |
1715 <simpleContent |
1822 <simpleContent |
1716 id = ID |
1823 id = ID |
1717 {any attributes with non-schema namespace . . .}> |
1824 {any attributes with non-schema namespace . . .}> |
1718 Content: (annotation?, (restriction | extension)) |
1825 Content: (annotation?, (restriction | extension)) |
1719 </simpleContent>""", |
1826 </simpleContent>""", |
1720 "type": SYNTAXELEMENT, |
1827 "type": SYNTAXELEMENT, |
1721 "extract": { |
1828 "extract": { |
1722 "default": GenerateElement("simpleContent", ["id"], |
1829 "default": GenerateElement( |
|
1830 "simpleContent", ["id"], |
1723 re.compile("((?:annotation )?(?:restriction |extension ))")) |
1831 re.compile("((?:annotation )?(?:restriction |extension ))")) |
1724 }, |
1832 }, |
1725 "reduce": ReduceSimpleContent |
1833 "reduce": ReduceSimpleContent |
1726 }, |
1834 }, |
1727 |
1835 |
1728 "simpleType": {"struct" : """ |
1836 "simpleType": { |
|
1837 "struct": """ |
1729 <simpleType |
1838 <simpleType |
1730 final = (#all | List of (list | union | restriction)) |
1839 final = (#all | List of (list | union | restriction)) |
1731 id = ID |
1840 id = ID |
1732 name = NCName |
1841 name = NCName |
1733 {any attributes with non-schema namespace . . .}> |
1842 {any attributes with non-schema namespace . . .}> |
1734 Content: (annotation?, (restriction | list | union)) |
1843 Content: (annotation?, (restriction | list | union)) |
1735 </simpleType>""", |
1844 </simpleType>""", |
1736 "type": SYNTAXELEMENT, |
1845 "type": SYNTAXELEMENT, |
1737 "extract": { |
1846 "extract": { |
1738 "default": GenerateElement("simpleType", ["final", "id", "name"], |
1847 "default": GenerateElement( |
|
1848 "simpleType", ["final", "id", "name"], |
1739 re.compile("((?:annotation )?(?:restriction |list |union ))")) |
1849 re.compile("((?:annotation )?(?:restriction |list |union ))")) |
1740 }, |
1850 }, |
1741 "reduce": ReduceSimpleType |
1851 "reduce": ReduceSimpleType |
1742 }, |
1852 }, |
1743 |
1853 |
1744 "totalDigits": {"struct" : """ |
1854 "totalDigits": { |
|
1855 "struct": """ |
1745 <totalDigits |
1856 <totalDigits |
1746 fixed = boolean : false |
1857 fixed = boolean : false |
1747 id = ID |
1858 id = ID |
1748 value = positiveInteger |
1859 value = positiveInteger |
1749 {any attributes with non-schema namespace . . .}> |
1860 {any attributes with non-schema namespace . . .}> |
1750 Content: (annotation?) |
1861 Content: (annotation?) |
1751 </totalDigits>""", |
1862 </totalDigits>""", |
1752 "type": SYNTAXELEMENT, |
1863 "type": SYNTAXELEMENT, |
1753 "extract": { |
1864 "extract": { |
1754 "default": GenerateElement("totalDigits", |
1865 "default": GenerateElement( |
1755 ["fixed", "id", "value"], ONLY_ANNOTATION), |
1866 "totalDigits", ["fixed", "id", "value"], ONLY_ANNOTATION), |
1756 }, |
1867 }, |
1757 "reduce": GenerateFacetReducing("totalDigits", True) |
1868 "reduce": GenerateFacetReducing("totalDigits", True) |
1758 }, |
1869 }, |
1759 |
1870 |
1760 "union": {"struct": """ |
1871 "union": { |
|
1872 "struct": """ |
1761 <union |
1873 <union |
1762 id = ID |
1874 id = ID |
1763 memberTypes = List of QName |
1875 memberTypes = List of QName |
1764 {any attributes with non-schema namespace . . .}> |
1876 {any attributes with non-schema namespace . . .}> |
1765 Content: (annotation?, simpleType*) |
1877 Content: (annotation?, simpleType*) |
1766 </union>""", |
1878 </union>""", |
1767 "type": SYNTAXELEMENT, |
1879 "type": SYNTAXELEMENT, |
1768 "extract": { |
1880 "extract": { |
1769 "default": GenerateElement("union", ["id", "memberTypes"], |
1881 "default": GenerateElement( |
|
1882 "union", ["id", "memberTypes"], |
1770 re.compile("((?:annotation )?(?:simpleType )*)")) |
1883 re.compile("((?:annotation )?(?:simpleType )*)")) |
1771 }, |
1884 }, |
1772 "reduce": ReduceUnion |
1885 "reduce": ReduceUnion |
1773 }, |
1886 }, |
1774 |
1887 |
1775 "unique": {"struct": """ |
1888 "unique": { |
|
1889 "struct": """ |
1776 <unique |
1890 <unique |
1777 id = ID |
1891 id = ID |
1778 name = NCName |
1892 name = NCName |
1779 {any attributes with non-schema namespace . . .}> |
1893 {any attributes with non-schema namespace . . .}> |
1780 Content: (annotation?, (selector, field+)) |
1894 Content: (annotation?, (selector, field+)) |
1781 </unique>""", |
1895 </unique>""", |
1782 "type": SYNTAXELEMENT, |
1896 "type": SYNTAXELEMENT, |
1783 "extract": { |
1897 "extract": { |
1784 "default": GenerateElement("unique", ["id", "name"], |
1898 "default": GenerateElement( |
|
1899 "unique", ["id", "name"], |
1785 re.compile("((?:annotation )?(?:selector |(?:field )+))")) |
1900 re.compile("((?:annotation )?(?:selector |(?:field )+))")) |
1786 }, |
1901 }, |
1787 "reduce": ReduceUnique |
1902 "reduce": ReduceUnique |
1788 }, |
1903 }, |
1789 |
1904 |
1790 "whiteSpace": {"struct" : """ |
1905 "whiteSpace": { |
|
1906 "struct": """ |
1791 <whiteSpace |
1907 <whiteSpace |
1792 fixed = boolean : false |
1908 fixed = boolean : false |
1793 id = ID |
1909 id = ID |
1794 value = (collapse | preserve | replace) |
1910 value = (collapse | preserve | replace) |
1795 {any attributes with non-schema namespace . . .}> |
1911 {any attributes with non-schema namespace . . .}> |
1796 Content: (annotation?) |
1912 Content: (annotation?) |
1797 </whiteSpace>""", |
1913 </whiteSpace>""", |
1798 "type": SYNTAXELEMENT, |
1914 "type": SYNTAXELEMENT, |
1799 "extract": { |
1915 "extract": { |
1800 "default": GenerateElement("whiteSpace", |
1916 "default": GenerateElement( |
1801 ["fixed", "id", "value"], ONLY_ANNOTATION) |
1917 "whiteSpace", ["fixed", "id", "value"], ONLY_ANNOTATION) |
1802 }, |
1918 }, |
1803 "reduce": GenerateFacetReducing("whiteSpace", True) |
1919 "reduce": GenerateFacetReducing("whiteSpace", True) |
1804 }, |
1920 }, |
1805 |
1921 |
1806 #------------------------------------------------------------------------------- |
1922 # ------------------------------------------------------------------------------- |
1807 # Syntax attributes definition |
1923 # Syntax attributes definition |
1808 #------------------------------------------------------------------------------- |
1924 # ------------------------------------------------------------------------------- |
1809 |
1925 |
1810 "abstract": { |
1926 "abstract": { |
1811 "type": SYNTAXATTRIBUTE, |
1927 "type": SYNTAXATTRIBUTE, |
1812 "extract": { |
1928 "extract": { |
1813 "default": GetBoolean |
1929 "default": GetBoolean |
1814 }, |
1930 }, |
1815 "default": { |
1931 "default": { |
1816 "default": False |
1932 "default": False |
1817 } |
1933 } |
1818 }, |
1934 }, |
1819 |
1935 |
1820 "attributeFormDefault": { |
1936 "attributeFormDefault": { |
1821 "type": SYNTAXATTRIBUTE, |
1937 "type": SYNTAXATTRIBUTE, |
1822 "extract": { |
1938 "extract": { |
1823 "default": GenerateEnumeratedExtraction("member attributeFormDefault", ["qualified", "unqualified"]) |
1939 "default": GenerateEnumeratedExtraction( |
|
1940 "member attributeFormDefault", ["qualified", "unqualified"]) |
1824 }, |
1941 }, |
1825 "default": { |
1942 "default": { |
1826 "default": "unqualified" |
1943 "default": "unqualified" |
1827 } |
1944 } |
1828 }, |
1945 }, |
1829 |
1946 |
1830 "base": { |
1947 "base": { |
1831 "type": SYNTAXATTRIBUTE, |
1948 "type": SYNTAXATTRIBUTE, |
1832 "extract": { |
1949 "extract": { |
1833 "default": GenerateModelNameExtraction("member base", QName_model) |
1950 "default": GenerateModelNameExtraction("member base", QName_model) |
1834 } |
1951 } |
1835 }, |
1952 }, |
1836 |
1953 |
1837 "block": { |
1954 "block": { |
1838 "type": SYNTAXATTRIBUTE, |
1955 "type": SYNTAXATTRIBUTE, |
1839 "extract": { |
1956 "extract": { |
1840 "default": GenerateGetList("block", ["restriction", "extension", "substitution"]) |
1957 "default": GenerateGetList("block", ["restriction", "extension", "substitution"]) |
1841 } |
1958 } |
1842 }, |
1959 }, |
1843 |
1960 |
1844 "blockDefault": { |
1961 "blockDefault": { |
1845 "type": SYNTAXATTRIBUTE, |
1962 "type": SYNTAXATTRIBUTE, |
1846 "extract": { |
1963 "extract": { |
1847 "default": GenerateGetList("block", ["restriction", "extension", "substitution"]) |
1964 "default": GenerateGetList("block", ["restriction", "extension", "substitution"]) |
1848 }, |
1965 }, |
1849 "default": { |
1966 "default": { |
1850 "default": "" |
1967 "default": "" |
1851 } |
1968 } |
1852 }, |
1969 }, |
1853 |
1970 |
1854 "default": { |
1971 "default": { |
1855 "type": SYNTAXATTRIBUTE, |
1972 "type": SYNTAXATTRIBUTE, |
1856 "extract": { |
1973 "extract": { |
1857 "default": GetAttributeValue |
1974 "default": GetAttributeValue |
1858 } |
1975 } |
1859 }, |
1976 }, |
1860 |
1977 |
1861 "elementFormDefault": { |
1978 "elementFormDefault": { |
1862 "type": SYNTAXATTRIBUTE, |
1979 "type": SYNTAXATTRIBUTE, |
1863 "extract": { |
1980 "extract": { |
1864 "default": GenerateEnumeratedExtraction("member elementFormDefault", ["qualified", "unqualified"]) |
1981 "default": GenerateEnumeratedExtraction("member elementFormDefault", ["qualified", "unqualified"]) |
1865 }, |
1982 }, |
1866 "default": { |
1983 "default": { |
1867 "default": "unqualified" |
1984 "default": "unqualified" |
1868 } |
1985 } |
1869 }, |
1986 }, |
1870 |
1987 |
1871 "final": { |
1988 "final": { |
1872 "type": SYNTAXATTRIBUTE, |
1989 "type": SYNTAXATTRIBUTE, |
1873 "extract": { |
1990 "extract": { |
1874 "default": GenerateGetList("final", ["restriction", "extension", "substitution"]), |
1991 "default": GenerateGetList("final", ["restriction", "extension", "substitution"]), |
1875 "simpleType": GenerateGetList("final", ["list", "union", "restriction"]) |
1992 "simpleType": GenerateGetList("final", ["list", "union", "restriction"]) |
1876 } |
1993 } |
1877 }, |
1994 }, |
1878 |
1995 |
1879 "finalDefault": { |
1996 "finalDefault": { |
1880 "type": SYNTAXATTRIBUTE, |
1997 "type": SYNTAXATTRIBUTE, |
1881 "extract": { |
1998 "extract": { |
1882 "default": GenerateGetList("finalDefault", ["restriction", "extension", "list", "union"]) |
1999 "default": GenerateGetList("finalDefault", ["restriction", "extension", "list", "union"]) |
1883 }, |
2000 }, |
1884 "default": { |
2001 "default": { |
1885 "default": "" |
2002 "default": "" |
1886 } |
2003 } |
1887 }, |
2004 }, |
1888 |
2005 |
1889 "fixed": { |
2006 "fixed": { |
1890 "type": SYNTAXATTRIBUTE, |
2007 "type": SYNTAXATTRIBUTE, |
1891 "extract": { |
2008 "extract": { |
1892 "default": GetBoolean, |
2009 "default": GetBoolean, |
1893 "attribute": GetAttributeValue, |
2010 "attribute": GetAttributeValue, |
1894 "element": GetAttributeValue |
2011 "element": GetAttributeValue |
1895 }, |
2012 }, |
2075 "default": GetToken |
2192 "default": GetToken |
2076 } |
2193 } |
2077 }, |
2194 }, |
2078 |
2195 |
2079 "xpath": { |
2196 "xpath": { |
2080 "type": SYNTAXATTRIBUTE, |
2197 "type": SYNTAXATTRIBUTE, |
2081 "extract": { |
2198 "extract": { |
2082 # "default": NotSupportedYet("xpath") |
2199 # "default": NotSupportedYet("xpath") |
2083 "default": GetAttributeValue |
2200 "default": GetAttributeValue |
2084 } |
2201 } |
2085 }, |
2202 }, |
2086 |
2203 |
2087 #------------------------------------------------------------------------------- |
2204 # ------------------------------------------------------------------------------- |
2088 # Simple types definition |
2205 # Simple types definition |
2089 #------------------------------------------------------------------------------- |
2206 # ------------------------------------------------------------------------------- |
2090 |
2207 |
2091 "string": { |
2208 "string": { |
2092 "type": SIMPLETYPE, |
2209 "type": SIMPLETYPE, |
2093 "basename": "string", |
2210 "basename": "string", |
2094 "extract": GetAttributeValue, |
2211 "extract": GetAttributeValue, |
2095 "facets": STRING_FACETS, |
2212 "facets": STRING_FACETS, |
2096 "generate": GenerateSimpleTypeXMLText(lambda x : x), |
2213 "generate": GenerateSimpleTypeXMLText(lambda x: x), |
2097 "initial": lambda: "", |
2214 "initial": lambda: "", |
2098 "check": lambda x: isinstance(x, (StringType, UnicodeType)) |
2215 "check": lambda x: isinstance(x, (StringType, UnicodeType)) |
2099 }, |
2216 }, |
2100 |
2217 |
2101 "normalizedString": { |
2218 "normalizedString": { |
2102 "type": SIMPLETYPE, |
2219 "type": SIMPLETYPE, |
2103 "basename": "normalizedString", |
2220 "basename": "normalizedString", |
2104 "extract": GetNormalizedString, |
2221 "extract": GetNormalizedString, |
2105 "facets": STRING_FACETS, |
2222 "facets": STRING_FACETS, |
2106 "generate": GenerateSimpleTypeXMLText(lambda x : x), |
2223 "generate": GenerateSimpleTypeXMLText(lambda x: x), |
2107 "initial": lambda: "", |
2224 "initial": lambda: "", |
2108 "check": lambda x: isinstance(x, (StringType, UnicodeType)) |
2225 "check": lambda x: isinstance(x, (StringType, UnicodeType)) |
2109 }, |
2226 }, |
2110 |
2227 |
2111 "token": { |
2228 "token": { |
2112 "type": SIMPLETYPE, |
2229 "type": SIMPLETYPE, |
2113 "basename": "token", |
2230 "basename": "token", |
2114 "extract": GetToken, |
2231 "extract": GetToken, |
2115 "facets": STRING_FACETS, |
2232 "facets": STRING_FACETS, |
2116 "generate": GenerateSimpleTypeXMLText(lambda x : x), |
2233 "generate": GenerateSimpleTypeXMLText(lambda x: x), |
2117 "initial": lambda: "", |
2234 "initial": lambda: "", |
2118 "check": lambda x: isinstance(x, (StringType, UnicodeType)) |
2235 "check": lambda x: isinstance(x, (StringType, UnicodeType)) |
2119 }, |
2236 }, |
2120 |
2237 |
2121 "base64Binary": { |
2238 "base64Binary": { |
2122 "type": SIMPLETYPE, |
2239 "type": SIMPLETYPE, |
2123 "basename": "base64Binary", |
2240 "basename": "base64Binary", |
2124 "extract": NotSupportedYet("base64Binary"), |
2241 "extract": NotSupportedYet("base64Binary"), |
2125 "facets": STRING_FACETS, |
2242 "facets": STRING_FACETS, |
2126 "generate": GenerateSimpleTypeXMLText(str), |
2243 "generate": GenerateSimpleTypeXMLText(str), |
2127 "initial": lambda: 0, |
2244 "initial": lambda: 0, |
2128 "check": lambda x: isinstance(x, (IntType, LongType)) |
2245 "check": lambda x: isinstance(x, (IntType, LongType)) |
2129 }, |
2246 }, |
2130 |
2247 |
2131 "hexBinary": { |
2248 "hexBinary": { |
2132 "type": SIMPLETYPE, |
2249 "type": SIMPLETYPE, |
2133 "basename": "hexBinary", |
2250 "basename": "hexBinary", |
2134 "extract": GetHexInteger, |
2251 "extract": GetHexInteger, |
2135 "facets": STRING_FACETS, |
2252 "facets": STRING_FACETS, |
2136 "generate": GenerateSimpleTypeXMLText(lambda x: ("%."+str(int(round(len("%X"%x)/2.)*2))+"X")%x), |
2253 "generate": GenerateSimpleTypeXMLText(lambda x: ("%."+str(int(round(len("%X" % x)/2.)*2))+"X") % x), |
2137 "initial": lambda: 0, |
2254 "initial": lambda: 0, |
2138 "check": lambda x: isinstance(x, (IntType, LongType)) |
2255 "check": lambda x: isinstance(x, (IntType, LongType)) |
2139 }, |
2256 }, |
2140 |
2257 |
2141 "integer": { |
2258 "integer": { |
2142 "type": SIMPLETYPE, |
2259 "type": SIMPLETYPE, |
2143 "basename": "integer", |
2260 "basename": "integer", |
2144 "extract": GenerateIntegerExtraction(), |
2261 "extract": GenerateIntegerExtraction(), |
2145 "facets": DECIMAL_FACETS, |
2262 "facets": DECIMAL_FACETS, |
2146 "generate": GenerateSimpleTypeXMLText(str), |
2263 "generate": GenerateSimpleTypeXMLText(str), |
2147 "initial": lambda: 0, |
2264 "initial": lambda: 0, |
2148 "check": lambda x: isinstance(x, IntType) |
2265 "check": lambda x: isinstance(x, IntType) |
2149 }, |
2266 }, |
2150 |
2267 |
2151 "positiveInteger": { |
2268 "positiveInteger": { |
2152 "type": SIMPLETYPE, |
2269 "type": SIMPLETYPE, |
2153 "basename": "positiveInteger", |
2270 "basename": "positiveInteger", |
2154 "extract": GenerateIntegerExtraction(minExclusive=0), |
2271 "extract": GenerateIntegerExtraction(minExclusive=0), |
2155 "facets": DECIMAL_FACETS, |
2272 "facets": DECIMAL_FACETS, |
2156 "generate": GenerateSimpleTypeXMLText(str), |
2273 "generate": GenerateSimpleTypeXMLText(str), |
2157 "initial": lambda: 1, |
2274 "initial": lambda: 1, |
2158 "check": lambda x: isinstance(x, IntType) |
2275 "check": lambda x: isinstance(x, IntType) |
2159 }, |
2276 }, |
2160 |
2277 |
2161 "negativeInteger": { |
2278 "negativeInteger": { |
2162 "type": SIMPLETYPE, |
2279 "type": SIMPLETYPE, |
2163 "basename": "negativeInteger", |
2280 "basename": "negativeInteger", |
2164 "extract": GenerateIntegerExtraction(maxExclusive=0), |
2281 "extract": GenerateIntegerExtraction(maxExclusive=0), |
2165 "facets": DECIMAL_FACETS, |
2282 "facets": DECIMAL_FACETS, |
2166 "generate": GenerateSimpleTypeXMLText(str), |
2283 "generate": GenerateSimpleTypeXMLText(str), |
2167 "initial": lambda: -1, |
2284 "initial": lambda: -1, |
2168 "check": lambda x: isinstance(x, IntType) |
2285 "check": lambda x: isinstance(x, IntType) |
2169 }, |
2286 }, |
2170 |
2287 |
2171 "nonNegativeInteger": { |
2288 "nonNegativeInteger": { |
2172 "type": SIMPLETYPE, |
2289 "type": SIMPLETYPE, |
2173 "basename": "nonNegativeInteger", |
2290 "basename": "nonNegativeInteger", |
2174 "extract": GenerateIntegerExtraction(minInclusive=0), |
2291 "extract": GenerateIntegerExtraction(minInclusive=0), |
2175 "facets": DECIMAL_FACETS, |
2292 "facets": DECIMAL_FACETS, |
2176 "generate": GenerateSimpleTypeXMLText(str), |
2293 "generate": GenerateSimpleTypeXMLText(str), |
2177 "initial": lambda: 0, |
2294 "initial": lambda: 0, |
2178 "check": lambda x: isinstance(x, IntType) |
2295 "check": lambda x: isinstance(x, IntType) |
2179 }, |
2296 }, |
2180 |
2297 |
2181 "nonPositiveInteger": { |
2298 "nonPositiveInteger": { |
2182 "type": SIMPLETYPE, |
2299 "type": SIMPLETYPE, |
2183 "basename": "nonPositiveInteger", |
2300 "basename": "nonPositiveInteger", |
2184 "extract": GenerateIntegerExtraction(maxInclusive=0), |
2301 "extract": GenerateIntegerExtraction(maxInclusive=0), |
2185 "facets": DECIMAL_FACETS, |
2302 "facets": DECIMAL_FACETS, |
2186 "generate": GenerateSimpleTypeXMLText(str), |
2303 "generate": GenerateSimpleTypeXMLText(str), |
2187 "initial": lambda: 0, |
2304 "initial": lambda: 0, |
2188 "check": lambda x: isinstance(x, IntType) |
2305 "check": lambda x: isinstance(x, IntType) |
2189 }, |
2306 }, |
2190 |
2307 |
2191 "long": { |
2308 "long": { |
2192 "type": SIMPLETYPE, |
2309 "type": SIMPLETYPE, |
2193 "basename": "long", |
2310 "basename": "long", |
2194 "extract": GenerateIntegerExtraction(minInclusive=-2**63,maxExclusive=2**63), |
2311 "extract": GenerateIntegerExtraction(minInclusive=-2**63, maxExclusive=2**63), |
2195 "facets": DECIMAL_FACETS, |
2312 "facets": DECIMAL_FACETS, |
2196 "generate": GenerateSimpleTypeXMLText(str), |
2313 "generate": GenerateSimpleTypeXMLText(str), |
2197 "initial": lambda: 0, |
2314 "initial": lambda: 0, |
2198 "check": lambda x: isinstance(x, IntType) |
2315 "check": lambda x: isinstance(x, IntType) |
2199 }, |
2316 }, |
2200 |
2317 |
2201 "unsignedLong": { |
2318 "unsignedLong": { |
2202 "type": SIMPLETYPE, |
2319 "type": SIMPLETYPE, |
2203 "basename": "unsignedLong", |
2320 "basename": "unsignedLong", |
2204 "extract": GenerateIntegerExtraction(minInclusive=0,maxExclusive=2**64), |
2321 "extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**64), |
2205 "facets": DECIMAL_FACETS, |
2322 "facets": DECIMAL_FACETS, |
2206 "generate": GenerateSimpleTypeXMLText(str), |
2323 "generate": GenerateSimpleTypeXMLText(str), |
2207 "initial": lambda: 0, |
2324 "initial": lambda: 0, |
2208 "check": lambda x: isinstance(x, IntType) |
2325 "check": lambda x: isinstance(x, IntType) |
2209 }, |
2326 }, |
2210 |
2327 |
2211 "int": { |
2328 "int": { |
2212 "type": SIMPLETYPE, |
2329 "type": SIMPLETYPE, |
2213 "basename": "int", |
2330 "basename": "int", |
2214 "extract": GenerateIntegerExtraction(minInclusive=-2**31,maxExclusive=2**31), |
2331 "extract": GenerateIntegerExtraction(minInclusive=-2**31, maxExclusive=2**31), |
2215 "facets": DECIMAL_FACETS, |
2332 "facets": DECIMAL_FACETS, |
2216 "generate": GenerateSimpleTypeXMLText(str), |
2333 "generate": GenerateSimpleTypeXMLText(str), |
2217 "initial": lambda: 0, |
2334 "initial": lambda: 0, |
2218 "check": lambda x: isinstance(x, IntType) |
2335 "check": lambda x: isinstance(x, IntType) |
2219 }, |
2336 }, |
2220 |
2337 |
2221 "unsignedInt": { |
2338 "unsignedInt": { |
2222 "type": SIMPLETYPE, |
2339 "type": SIMPLETYPE, |
2223 "basename": "unsignedInt", |
2340 "basename": "unsignedInt", |
2224 "extract": GenerateIntegerExtraction(minInclusive=0,maxExclusive=2**32), |
2341 "extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**32), |
2225 "facets": DECIMAL_FACETS, |
2342 "facets": DECIMAL_FACETS, |
2226 "generate": GenerateSimpleTypeXMLText(str), |
2343 "generate": GenerateSimpleTypeXMLText(str), |
2227 "initial": lambda: 0, |
2344 "initial": lambda: 0, |
2228 "check": lambda x: isinstance(x, IntType) |
2345 "check": lambda x: isinstance(x, IntType) |
2229 }, |
2346 }, |
2230 |
2347 |
2231 "short": { |
2348 "short": { |
2232 "type": SIMPLETYPE, |
2349 "type": SIMPLETYPE, |
2233 "basename": "short", |
2350 "basename": "short", |
2234 "extract": GenerateIntegerExtraction(minInclusive=-2**15,maxExclusive=2**15), |
2351 "extract": GenerateIntegerExtraction(minInclusive=-2**15, maxExclusive=2**15), |
2235 "facets": DECIMAL_FACETS, |
2352 "facets": DECIMAL_FACETS, |
2236 "generate": GenerateSimpleTypeXMLText(str), |
2353 "generate": GenerateSimpleTypeXMLText(str), |
2237 "initial": lambda: 0, |
2354 "initial": lambda: 0, |
2238 "check": lambda x: isinstance(x, IntType) |
2355 "check": lambda x: isinstance(x, IntType) |
2239 }, |
2356 }, |
2240 |
2357 |
2241 "unsignedShort": { |
2358 "unsignedShort": { |
2242 "type": SIMPLETYPE, |
2359 "type": SIMPLETYPE, |
2243 "basename": "unsignedShort", |
2360 "basename": "unsignedShort", |
2244 "extract": GenerateIntegerExtraction(minInclusive=0,maxExclusive=2**16), |
2361 "extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**16), |
2245 "facets": DECIMAL_FACETS, |
2362 "facets": DECIMAL_FACETS, |
2246 "generate": GenerateSimpleTypeXMLText(str), |
2363 "generate": GenerateSimpleTypeXMLText(str), |
2247 "initial": lambda: 0, |
2364 "initial": lambda: 0, |
2248 "check": lambda x: isinstance(x, IntType) |
2365 "check": lambda x: isinstance(x, IntType) |
2249 }, |
2366 }, |
2250 |
2367 |
2251 "byte": { |
2368 "byte": { |
2252 "type": SIMPLETYPE, |
2369 "type": SIMPLETYPE, |
2253 "basename": "byte", |
2370 "basename": "byte", |
2254 "extract": GenerateIntegerExtraction(minInclusive=-2**7,maxExclusive=2**7), |
2371 "extract": GenerateIntegerExtraction(minInclusive=-2**7, maxExclusive=2**7), |
2255 "facets": DECIMAL_FACETS, |
2372 "facets": DECIMAL_FACETS, |
2256 "generate": GenerateSimpleTypeXMLText(str), |
2373 "generate": GenerateSimpleTypeXMLText(str), |
2257 "initial": lambda: 0, |
2374 "initial": lambda: 0, |
2258 "check": lambda x: isinstance(x, IntType) |
2375 "check": lambda x: isinstance(x, IntType) |
2259 }, |
2376 }, |
2260 |
2377 |
2261 "unsignedByte": { |
2378 "unsignedByte": { |
2262 "type": SIMPLETYPE, |
2379 "type": SIMPLETYPE, |
2263 "basename": "unsignedByte", |
2380 "basename": "unsignedByte", |
2264 "extract": GenerateIntegerExtraction(minInclusive=0,maxExclusive=2**8), |
2381 "extract": GenerateIntegerExtraction(minInclusive=0, maxExclusive=2**8), |
2265 "facets": DECIMAL_FACETS, |
2382 "facets": DECIMAL_FACETS, |
2266 "generate": GenerateSimpleTypeXMLText(str), |
2383 "generate": GenerateSimpleTypeXMLText(str), |
2267 "initial": lambda: 0, |
2384 "initial": lambda: 0, |
2268 "check": lambda x: isinstance(x, IntType) |
2385 "check": lambda x: isinstance(x, IntType) |
2269 }, |
2386 }, |