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