diff -r c74815729afd -r 691083b5682a xmlclass/xsdschema.py --- a/xmlclass/xsdschema.py Fri Aug 18 12:36:31 2017 +0300 +++ b/xmlclass/xsdschema.py Fri Aug 18 20:14:38 2017 +0300 @@ -75,8 +75,8 @@ STRING_FACETS = GenerateDictFacets(DEFAULT_FACETS.keys() + ["length", "minLength", "maxLength"]) ALL_FACETS = ["pattern", "whiteSpace", "enumeration", "maxInclusive", - "maxExclusive", "minInclusive", "minExclusive", "totalDigits", - "fractionDigits", "length", "minLength", "maxLength"] + "maxExclusive", "minInclusive", "minExclusive", "totalDigits", + "fractionDigits", "length", "minLength", "maxLength"] #------------------------------------------------------------------------------- @@ -1143,7 +1143,8 @@ # Syntax elements definition #------------------------------------------------------------------------------- - "all": {"struct": """ + "all": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("all", ["id", "maxOccurs", "minOccurs"], + "default": GenerateElement( + "all", ["id", "maxOccurs", "minOccurs"], re.compile("((?:annotation )?(?:element )*)")) }, "reduce": ReduceAll }, - "annotation": {"struct": """ + "annotation": { + "struct": """ @@ -1167,13 +1170,15 @@ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("annotation", ["id"], + "default": GenerateElement( + "annotation", ["id"], re.compile("((?:app_info |documentation )*)")) }, "reduce": ReduceAnnotation }, - "any": {"struct": """ + "any": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("any", + "default": GenerateElement( + "any", ["id", "maxOccurs", "minOccurs", "namespace", "processContents"], re.compile("((?:annotation )?(?:simpleType )*)")) }, "reduce": ReduceAny }, - "anyAttribute": {"struct": """ + "anyAttribute": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("anyAttribute", - ["id", "namespace", "processContents"], ONLY_ANNOTATION) + "default": GenerateElement( + "anyAttribute", ["id", "namespace", "processContents"], ONLY_ANNOTATION) }, "reduce": ReduceAnyAttribute }, - "appinfo": {"struct": """ + "appinfo": { + "struct": """ @@ -1221,7 +1229,8 @@ "reduce": ReduceAppInfo }, - "attribute": {"struct": """ + "attribute": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("attribute", + "default": GenerateElement( + "attribute", ["default", "fixed", "form", "id", "name", "ref", "type", "use"], re.compile("((?:annotation )?(?:simpleType )?)")), - "schema": GenerateElement("attribute", + "schema": GenerateElement( + "attribute", ["default", "fixed", "form", "id", "name", "type"], re.compile("((?:annotation )?(?:simpleType )?)")) }, "reduce": ReduceAttribute }, - "attributeGroup": {"struct": """ + "attributeGroup": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("attributeGroup", + "default": GenerateElement( + "attributeGroup", ["id", "ref"], ONLY_ANNOTATION), - "schema": GenerateElement("attributeGroup", + "schema": GenerateElement( + "attributeGroup", ["id", "name"], re.compile("((?:annotation )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")) }, "reduce": ReduceAttributeGroup }, - "choice": {"struct": """ + "choice": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("choice", ["id", "maxOccurs", "minOccurs"], + "default": GenerateElement( + "choice", + ["id", "maxOccurs", "minOccurs"], re.compile("((?:annotation )?(?:element |group |choice |sequence |any )*)")) }, "reduce": ReduceChoice }, - "complexContent": {"struct": """ + "complexContent": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("complexContent", ["id", "mixed"], + "default": GenerateElement( + "complexContent", + ["id", "mixed"], re.compile("((?:annotation )?(?:restriction |extension ))")) }, "reduce": ReduceComplexContent }, - "complexType": {"struct": """ + "complexType": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("complexType", + "default": GenerateElement( + "complexType", ["abstract", "block", "final", "id", "mixed", "name"], re.compile("((?:annotation )?(?:simpleContent |complexContent |(?:(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))))")) }, "reduce": ReduceComplexType }, - "documentation": {"struct": """ + "documentation": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("documentation", - ["source", "lang"], re.compile("(.*)"), True) + "default": GenerateElement( + "documentation", + ["source", "lang"], + re.compile("(.*)"), True) }, "reduce": ReduceDocumentation }, - "element": {"struct": """ + "element": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("element", + "default": GenerateElement( + "element", ["abstract", "block", "default", "final", "fixed", "form", "id", "maxOccurs", "minOccurs", "name", "nillable", "ref", "substitutionGroup", "type"], re.compile("((?:annotation )?(?:simpleType |complexType )?(?:unique |key |keyref )*)")), - "schema": GenerateElement("element", + "schema": GenerateElement( + "element", ["abstract", "block", "default", "final", "fixed", "form", "id", "name", "nillable", "substitutionGroup", "type"], re.compile("((?:annotation )?(?:simpleType |complexType )?(?:unique |key |keyref )*)")) }, "reduce": ReduceElement }, - "enumeration": {"struct": """ + "enumeration": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("extension", ["base", "id"], + "default": GenerateElement( + "extension", + ["base", "id"], re.compile("((?:annotation )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")), - "complexContent": GenerateElement("extension", ["base", "id"], + "complexContent": GenerateElement( + "extension", + ["base", "id"], re.compile("((?:annotation )?(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?))")) }, "reduce": ReduceExtension }, - "field": {"struct": """ + "field": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("fractionDigits", - ["fixed", "id", "value"], ONLY_ANNOTATION) + "default": GenerateElement( + "fractionDigits", + ["fixed", "id", "value"], + ONLY_ANNOTATION) }, "reduce": GenerateFacetReducing("fractionDigits", True) }, - "group": {"struct": """ + "group": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("group", + "default": GenerateElement( + "group", ["id", "maxOccurs", "minOccurs", "ref"], re.compile("((?:annotation )?(?:all |choice |sequence )?)")), - "schema": GenerateElement("group", + "schema": GenerateElement( + "group", ["id", "name"], re.compile("((?:annotation )?(?:all |choice |sequence )?)")) }, "reduce": ReduceGroup }, - "import": {"struct": """ + "import": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("import", - ["id", "namespace", "schemaLocation"], ONLY_ANNOTATION) + "default": GenerateElement( + "import", + ["id", "namespace", "schemaLocation"], + ONLY_ANNOTATION) }, "reduce": ReduceImport }, - "include": {"struct": """ + "include": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("include", - ["id", "schemaLocation"], ONLY_ANNOTATION) + "default": GenerateElement( + "include", + ["id", "schemaLocation"], + ONLY_ANNOTATION) }, "reduce": ReduceInclude }, - "key": {"struct": """ + "key": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("key", ["id", "name"], + "default": GenerateElement( + "key", ["id", "name"], re.compile("((?:annotation )?(?:selector (?:field )+))")) }, "reduce": ReduceKey }, - "keyref": {"struct": """ + "keyref": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("keyref", ["id", "name", "refer"], + "default": GenerateElement( + "keyref", ["id", "name", "refer"], re.compile("((?:annotation )?(?:selector (?:field )+))")) }, "reduce": ReduceKeyRef }, - "length": {"struct": """ + "length": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("length", - ["fixed", "id", "value"], ONLY_ANNOTATION) + "default": GenerateElement( + "length", ["fixed", "id", "value"], ONLY_ANNOTATION) }, "reduce": GenerateFacetReducing("length", True) }, - "list": {"struct": """ + "list": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("list", ["id", "itemType"], + "default": GenerateElement( + "list", ["id", "itemType"], re.compile("((?:annotation )?(?:simpleType )?)$")) }, "reduce": ReduceList }, - "maxExclusive": {"struct": """ + "maxExclusive": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("maxExclusive", - ["fixed", "id", "value"], ONLY_ANNOTATION) + "default": GenerateElement( + "maxExclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) }, "reduce": GenerateFacetReducing("maxExclusive", True) }, - "maxInclusive": {"struct": """ + "maxInclusive": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("maxInclusive", - ["fixed", "id", "value"], ONLY_ANNOTATION) + "default": GenerateElement( + "maxInclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) }, "reduce": GenerateFacetReducing("maxInclusive", True) }, - "maxLength": {"struct": """ + "maxLength": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("maxLength", - ["fixed", "id", "value"], ONLY_ANNOTATION) + "default": GenerateElement( + "maxLength", ["fixed", "id", "value"], ONLY_ANNOTATION) }, "reduce": GenerateFacetReducing("maxLength", True) }, - "minExclusive": {"struct": """ + "minExclusive": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("minExclusive", - ["fixed", "id", "value"], ONLY_ANNOTATION) + "default": GenerateElement( + "minExclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) }, "reduce": GenerateFacetReducing("minExclusive", True) }, - "minInclusive": {"struct": """ + "minInclusive": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("minInclusive", - ["fixed", "id", "value"], ONLY_ANNOTATION) + "default": GenerateElement( + "minInclusive", ["fixed", "id", "value"], ONLY_ANNOTATION) }, "reduce": GenerateFacetReducing("minInclusive", True) }, - "minLength": {"struct": """ + "minLength": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("minLength", - ["fixed", "id", "value"], ONLY_ANNOTATION) + "default": GenerateElement( + "minLength", ["fixed", "id", "value"], ONLY_ANNOTATION) }, "reduce": GenerateFacetReducing("minLength", True) }, - "pattern": {"struct": """ + "pattern": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("refine", ["id", "schemaLocation"], + "default": GenerateElement( + "refine", ["id", "schemaLocation"], re.compile("((?:annotation |(?:simpleType |complexType |group |attributeGroup ))*)")) }, "reduce": ReduceRedefine }, - "restriction": {"struct": """ + "restriction": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("restriction", ["base", "id"], + "default": GenerateElement( + "restriction", + ["base", "id"], re.compile("((?:annotation )?(?:(?:simpleType )?(?:(?:minExclusive |minInclusive |maxExclusive |maxInclusive |totalDigits |fractionDigits |length |minLength |maxLength |enumeration |whiteSpace |pattern )*)))")), - "simpleContent": GenerateElement("restriction", ["base", "id"], + "simpleContent": GenerateElement( + "restriction", + ["base", "id"], re.compile("((?:annotation )?(?:(?:simpleType )?(?:(?:minExclusive |minInclusive |maxExclusive |maxInclusive |totalDigits |fractionDigits |length |minLength |maxLength |enumeration |whiteSpace |pattern )*)?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?)))")), - "complexContent": GenerateElement("restriction", ["base", "id"], + "complexContent": GenerateElement( + "restriction", + ["base", "id"], re.compile("((?:annotation )?(?:(?:simpleType )?(?:group |all |choice |sequence )?(?:(?:attribute |attributeGroup )*(?:anyAttribute )?)))")), }, "reduce": ReduceRestriction }, - "schema": {"struct": """ + "schema": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("schema", - ["attributeFormDefault", "blockDefault", "elementFormDefault", "finalDefault", "id", "targetNamespace", "version", "lang"], + "default": GenerateElement( + "schema", + ["attributeFormDefault", + "blockDefault", + "elementFormDefault", + "finalDefault", + "id", + "targetNamespace", + "version", + "lang"], re.compile("((?:include |import |redefine |annotation )*(?:(?:(?:simpleType |complexType |group |attributeGroup )|element |attribute |annotation )(?:annotation )*)*)")) } }, - "selector": {"struct": """ + "selector": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("sequence", ["id", "maxOccurs", "minOccurs"], + "default": GenerateElement( + "sequence", ["id", "maxOccurs", "minOccurs"], re.compile("((?:annotation )?(?:element |group |choice |sequence |any )*)")) }, "reduce": ReduceSequence }, - "simpleContent": {"struct": """ + "simpleContent": { + "struct": """ @@ -1741,13 +1824,15 @@ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("simpleContent", ["id"], + "default": GenerateElement( + "simpleContent", ["id"], re.compile("((?:annotation )?(?:restriction |extension ))")) }, "reduce": ReduceSimpleContent }, - "simpleType": {"struct": """ + "simpleType": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("simpleType", ["final", "id", "name"], + "default": GenerateElement( + "simpleType", ["final", "id", "name"], re.compile("((?:annotation )?(?:restriction |list |union ))")) }, "reduce": ReduceSimpleType }, - "totalDigits": {"struct": """ + "totalDigits": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("totalDigits", - ["fixed", "id", "value"], ONLY_ANNOTATION), + "default": GenerateElement( + "totalDigits", ["fixed", "id", "value"], ONLY_ANNOTATION), }, "reduce": GenerateFacetReducing("totalDigits", True) }, - "union": {"struct": """ + "union": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("union", ["id", "memberTypes"], + "default": GenerateElement( + "union", ["id", "memberTypes"], re.compile("((?:annotation )?(?:simpleType )*)")) }, "reduce": ReduceUnion }, - "unique": {"struct": """ + "unique": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("unique", ["id", "name"], + "default": GenerateElement( + "unique", ["id", "name"], re.compile("((?:annotation )?(?:selector |(?:field )+))")) }, "reduce": ReduceUnique }, - "whiteSpace": {"struct": """ + "whiteSpace": { + "struct": """ """, "type": SYNTAXELEMENT, "extract": { - "default": GenerateElement("whiteSpace", - ["fixed", "id", "value"], ONLY_ANNOTATION) + "default": GenerateElement( + "whiteSpace", ["fixed", "id", "value"], ONLY_ANNOTATION) }, "reduce": GenerateFacetReducing("whiteSpace", True) }, @@ -1842,7 +1934,8 @@ "attributeFormDefault": { "type": SYNTAXATTRIBUTE, "extract": { - "default": GenerateEnumeratedExtraction("member attributeFormDefault", ["qualified", "unqualified"]) + "default": GenerateEnumeratedExtraction( + "member attributeFormDefault", ["qualified", "unqualified"]) }, "default": { "default": "unqualified"