# ----------------------------------------
class X_definitionComposee (X_definition):
-# ----------------------------------------
+# ------------------------------------------
def CreeTexteComplexeVenantDesFils(self):
texteComplexeVenantDesFils=""
fichierDejaDumpe = True
return texteComplexeVenantDesFils
- def dumpXsd(self):
+ def dumpXsd(self, inExtension=False):
#print ('------------------------------------------------')
#print ('dumpXsd de ' , self.nom)
if PourTraduction : print (self.nom)
#
if self.aCreer :
self.texteComplexe = debutTypeCompo.format(self.nomDuTypePyxb)
+ if inExtension : self.texteComplexe += debutEtension.format(self.code)
+ self.texteComplexe += debutTypeCompoSeq
texteComplexeVenantDesFils=self.CreeTexteComplexeVenantDesFils()
self.texteComplexe = texteComplexeVenantDesFils + self.texteComplexe
- if not isinstance(self,X_OPER ) : self.texteComplexe += finTypeCompo
+ if not isinstance(self,X_OPER ) :
+ self.texteComplexe += finTypeCompo
+ if inExtension : self.texteComplexe += finExtension
+ self.texteComplexe += finTypeCompoSeq
else :
self.texteComplexe = ""
# ______________________
# valable pour PROC et OPER
self.minOccurs = 0
- self.maxOccurs = "unbounded"
+ self.maxOccurs = 1
def compare(self,autreMC):
if self.label != autreMC.label : return False
self.texteSimple += fermeSimpleType
- #if self.max > 1 : self.isListe=True
- #else : self.isListe =False
- #if self.aCreer == True :
- # if self.isListe : self.texteSimple = debutTypeSimpleListe.format(self.nomDuTypePyxb, self.nomDuTypeDeBase)
- # else : self.texteSimple = debutTypeSimple.format (self.nomDuTypePyxb, self.nomDuTypeDeBase)
- # if self.into != None:
- # self.texteSimple = self.texteSimple + ">\n"
- # for val in self.into :
- # self.texteSimple += withInto.format(val)
- # self.texteSimple += finWithInto
- # else :
- # self.texteSimple += fermeBalise
- # self.texteSimple += finTypeSimple
- #else :
- # le type existe deja
-
def traduitType(self):
# il faut traduire le min et le max
if hasattr(self.type[0], 'ntuple') : return ('XXXXXXXX')
if not (self.type[0] in list(dictNomsDesTypes.keys())) :
- if (isinstance(self.type[0], Accas.ASSD) or issubclass(self.type[0], Accas.ASSD)) : return 'string'
+ if (isinstance(self.type[0], Accas.ASSD) or issubclass(self.type[0], Accas.ASSD)) : return 'xs:string'
else : return ('YYYYY')
return dictNomsDesTypes[self.type[0]]
#-----------------
def dumpXsd(self):
-
- #for name, obj in inspect.getmembers(self.module):
- # if inspect.isclass(obj):
- # if issubclass(obj,Accas.UserASSD) :
- # source = inspect.getsourcefile(obj)
- # if source.split('/')[-1] != "A_ASSD.py" :
- # typeASSD= 'UserASSD'
- # textDeclaration += debutAccasClass.format('T_'+obj.__name__,typeASSD)
+ cata = CONTEXT.getCurrentCata()
+ if self.fichierSource != self.module.__file__ :
+ self.dumpDifferenceModuleMetier()
+ return
self.texteSimple = ""
self.texteComplexe = ""
self.nomDuTypePyxb='T_'+self.code
self.texteSimple += commande.texteSimple
self.texteSimple += commande.texteComplexe
self.texteCata += commande.texteElt
- self.texteCata += finTypeCata
- self.texteElt=eltCata.format(self.code,self.code, self.nomDuTypePyxb)
+ self.texteSimple += TypeEtEltAbstraitCodeSpec.format(self.code)
+ self.texteCata += EltCodeSpecDsCata.format(self.code)
+ self.texteCata += finTypeCata
+ self.texteElt = eltCata.format(self.code,self.code, self.nomDuTypePyxb)
self.texteXSD = texteDebut.format(self.code,self.code,self.code)
#self.texteXSD += textDeclaration
self.texteXSD += self.texteCata
self.texteXSD += self.texteElt
self.texteXSD += texteFin
- #print (self.texteSimple)
- #print (self.texteCata)
- #print (self.texteElt)
print (self.texteXSD)
dico = {}
- cata = CONTEXT.getCurrentCata()
for k in list(cata.dictTypesXSD.keys()):
if len(cata.dictTypesXSD[k]) > 1:
index=0
#pprint.pprint(dico)
+ def dumpDifferenceModuleMetier(self):
+ fichierSourceExt=os.path.basename(self.fichierSource)
+ fichierSource, extension=os.path.splitext(fichierSourceExt)
+
+ allClassFromVimp=[]
+ o=__import__(fichierSource,{},{})
+ for k,d in inspect.getmembers(o):
+ allClassFromVimp.append(k)
+
+ allClassToDump=[]
+ for key, data in inspect.getmembers(self.module):
+ if key in allClassFromVimp : continue
+ if key != "modeleMetier" : allClassToDump.append(data)
+
+ self.texteSimple = ""
+ self.texteComplexe = ""
+ self.texteCata = texteDebut.format(self.code,self.code,self.code)
+ self.texteCata += includeCata.format(self.code)
+ self.texteElt = ""
+
+ for c in allClassToDump :
+ if (isinstance(c, Accas.ETAPE)) : print (c, 'aDumper')
+ c.code=self.code
+ c.dumpXsd(inExtension=True)
+ self.texteSimple += c.texteSimple
+ self.texteSimple += c.texteComplexe
+ self.texteElt += c.texteElt
+ #print (self.texteCata)
+ #print (self.texteSimple)
+ #print (self.texteElt)
+ self.texteXSD = self.texteCata+'\n'+self.texteSimple+'\n'+self.texteElt+'\n'+texteFin+'\n'
+ print (self.texteXSD)
-texteDebut='<?xml version="1.0" encoding="UTF-8"?>\n<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:{}="http://chercheurs.edf.com/logiciels/{}" targetNamespace="http://chercheurs.edf.com/logiciels/{}" elementFormDefault="qualified" attributeFormDefault="qualified">\n'
-texteFin='</schema>'
-fermeBalise = "/>"
+#texteDebut='<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\nxmlns="http://chercheurs.edf.com/logiciels/Vimmp"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}" xmlns:spc="http://chercheurs.edf.com/logiciels/VimmpSpec" targetNamespace="http://chercheurs.edf.com/logiciels/Vimmp" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0">\n'
+texteDebut='<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\nxmlns="http://chercheurs.edf.com/logiciels/Vimmp"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\ntargetNamespace="http://chercheurs.edf.com/logiciels/Vimmp"\nelementFormDefault="qualified" attributeFormDefault="unqualified" version="0">\n'
+texteFin='</xs:schema>'
+texteDebutCataSpecifique='<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:VimmpSpec="http://chercheurs.edf.com/logiciels/VimmpSpec" xmlns="http://chercheurs.edf.com/logiciels/VimmpSpec" targetNamespace="http://chercheurs.edf.com/logiciels/VimmpSpec" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0">'
# SIMP
-debutSimpleType = '\t<simpleType name="{}">\n'
-fermeSimpleType = '\t</simpleType>\n'
-debutRestrictionBase = '\t\t<restriction base="{}">\n'
-fermeRestrictionBase = '\t\t</restriction>\n'
-enumeration = '\t\t\t<enumeration value="{}"/>\n'
-maxInclusiveBorne = '\t\t\t<maxInclusive value = "{}"/>\n'
-minInclusiveBorne = '\t\t\t<minInclusive value = "{}"/>\n'
+debutSimpleType = '\t<xs:simpleType name="{}">\n'
+fermeSimpleType = '\t</xs:simpleType>\n'
+debutRestrictionBase = '\t\t<xs:restriction base="{}">\n'
+fermeRestrictionBase = '\t\t</xs:restriction>\n'
+enumeration = '\t\t\t<xs:enumeration value="{}"/>\n'
+maxInclusiveBorne = '\t\t\t<xs:maxInclusive value = "{}"/>\n'
+minInclusiveBorne = '\t\t\t<xs:minInclusive value = "{}"/>\n'
-debutTypeSimpleListe = '\t\t<restriction>\n\t\t\t<simpleType>\n\t\t\t\t<list>\n\t\t\t\t\t<simpleType>\n'
-finTypeSimpleListe = '\t\t<restriction>\n\t\t\t<simpleType>\n\t\t\t\t<list>\n\t\t\t\t\t<simpleType>\n'
-fermeBalisesMileu = '\t\t\t\t\t\t</restriction>\n\t\t\t\t\t</simpleType>\n\t\t\t\t</list>\n\t\t\t </simpleType>\n'
+debutTypeSimpleListe = '\t\t<xs:restriction>\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:list>\n\t\t\t\t\t<xs:simpleType>\n'
+finTypeSimpleListe = '\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t\t\t</xs:list>\n\t\t\t\t\t</xs:simpleType>\n'
+fermeBalisesMileu = '\t\t\t\t\t\t</xs:restriction>\n\t\t\t\t\t</xs:simpleType>\n\t\t\t\t</xs:list>\n\t\t\t </xs:simpleType>\n'
-maxLengthTypeSimple = '\t\t\t<maxLength value = "{}"/>\n'
-minLengthTypeSimple = '\t\t\t<minLength value = "{}"/>\n'
-eltDsSequence = '\t\t\t<element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
-eltWithDefautDsSequence = '\t\t\t<element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}" default="{}"/>\n'
+maxLengthTypeSimple = '\t\t\t<xs:maxLength value = "{}"/>\n'
+minLengthTypeSimple = '\t\t\t<xs:minLength value = "{}"/>\n'
+eltDsSequence = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
+eltWithDefautDsSequence = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}" default="{}"/>\n'
# COMPO
-#debutTypeCompo = '\t<complexType name="{}" >\n\t\t<sequence minOccurs="{}" maxOccurs="{}">\n'
-debutTypeCompo = '\t<complexType name="{}" >\n\t\t<sequence>\n'
-finTypeCompo = '\t\t</sequence>\n\t</complexType>\n'
-eltCompoDsSequence = '\t\t\t<element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
+debutTypeCompo = '\t<xs:complexType name="{}" >\n'
+debutTypeCompoSeq = '\t\t<xs:sequence>\n'
+finTypeCompo = '\t\t</xs:sequence>\n'
+finTypeCompoSeq = '\t</xs:complexType>\n'
+eltCompoDsSequence = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
# BLOC
-debutTypeSubst = '\t<group name="{}"> \n\t\t<sequence>\n'
-finTypeSubst = '\t\t</sequence>\n\t</group>\n'
-substDsSequence = '\t\t\t<group ref="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
+debutTypeSubst = '\t<xs:group name="{}"> \n\t\t<xs:sequence>\n'
+finTypeSubst = '\t\t</xs:sequence>\n\t</xs:group>\n'
+substDsSequence = '\t\t\t<xs:group ref="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
# User OR ASSD
-operAttributeName = '\t\t<attribute name="nom" type="string"/>\n'
-attributeTypeForASSD = '\t\t<attribute name="acassType" type="string" fixed="ASSD"/>\n'
-attributeTypeUtilisateurName = '\t\t<attribute name="typeUtilisateur" type="string" fixed="{}"/>\n'
+operAttributeName = '\t\t<xs:attribute name="nom" type="xs:string"/>\n'
+attributeTypeForASSD = '\t\t<xs:attribute name="acassType" type="xs:string" fixed="ASSD"/>\n'
+attributeTypeUtilisateurName = '\t\t<xs:attribute name="typeUtilisateur" type="xs:string" fixed="{}"/>\n'
#keyRefDeclaration ='\n\t<xs:keyref name="{}_Name_ref" refer="Key_Name_In_{}"> \n\t\t<xs:selector xpath="{}:{}_Name"/>\n\t\t<xs:field xpath="."/>\n\t</xs:keyref>\n'
# CATA
-debutTypeCata = '\t<complexType name="{}">\n\t\t<choice minOccurs="0" maxOccurs="unbounded">\n'
-finTypeCata = '\t\t</choice>\n\t</complexType> '
-eltCata = '\t<element name="{}" type="{}:{}"/>\n'
+debutTypeCata = '\t<xs:complexType name="{}">\n\t\t<xs:choice minOccurs="0" maxOccurs="unbounded">\n'
+finTypeCata = '\t\t</xs:choice>\n\t</xs:complexType>\n'
+finSchema = '</xs:schema>'
+eltCata = '\t<xs:element name="{}" type="{}:{}"/>\n'
+TypeEtEltAbstraitCodeSpec = '\t<xs:complexType name="T_Code_Specific" abstract="true"/>\n\t<xs:element name="Code_Specific" type="{}:T_Code_Specific"/>\n'
+EltCodeSpecDsCata='\t\t\t<xs:element ref="{}:Code_Specific" minOccurs="0" maxOccurs="1"/>\n'
+includeCata = '\t<xs:include schemaLocation="cata_{}_genere.xsd" />\n\n'
+
+# EXTENSION
+debutEtension = '\t\t<xs:complexContent>\n\t\t<xs:extension base="{}:T_Code_Specific">\n'
+finExtension = '\t\t</xs:extension>\n\t\t</xs:complexContent>\n'
if __name__ == '__main__' :