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