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