else :
self.texteComplexe = ""
- minDsSequence=0
- if hasattr(self, 'statut') and self.statut=='f' : minDsSequence=0
- maxDsSequence=1
- if self.label in ('BLOC', 'FACT'):
- self.texteElt=eltCompoDsSequence.format(self.nom,self.code,self.nomDuTypePyxb,minDsSequence,maxDsSequence)
- else :
- self.texteElt=eltCompoDsSequenceSiProc.format(self.nom,self.code,self.nomDuTypePyxb)
+ self.texteElt=eltCompoDsSequence.format(self.nom,self.code,self.nomDuTypePyxb,self.minOccurs,self.maxOccurs)
#print (self.texteComplexe)
#print ('------------------------------------------------')
def traduitMinMax(self):
- # ____________________
- # valable pour bloc, proc et oper
+ # ______________________
+ # valable pour PROC et OPER
self.minOccurs = 0
- self.maxOccurs = 1
+ self.maxOccurs = "unbounded"
def compare(self,autreMC):
if self.label != autreMC.label : return False
#print ('exploreObjet SIMP')
self.getCode()
self.aCreer = True
+ self.texteComplexe = ""
+ self.texteSimple = ""
- # --> homonymie on peut utiliser genealogie
- #self.traduitMinMax()
- #self.traduitValMinValMax()
+ # --> homonymie on peut utiliser genealogie ?
self.nomDuTypeDeBase = self.traduitType()
self.nomDuTypePyxb = self.definitNomDuTypePyxb()
- if self.aCreer == True :
- 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 += finRestriction
- self.texteSimple += finTypeSimple
- else :
- # le type existe deja
- self.texteSimple=""
- self.texteComplexe = ""
- # on se sert des listes si maxOccurs est > 0
- # a gerer dans le dump
+ # on se sert des listes ou non pour la gestion des minOccurs /maxOccurs est > 0
if self.statut =='f' : minOccurs = 0
else : minOccurs = 1
+ # le defaut est dans l elt Name -> tester la coherence d existence avec Accas
+ # regles Accas
self.texteElt = eltDsSequence.format(self.nom,self.code,self.nomDuTypePyxb,minOccurs,1)
+
+ # self.aCreer est mis a jour ds definitNomDuTypePyxb
+ if not self.aCreer : return
+
+ self.texteSimple += debTypeSimpleNom.format(self.nomDuTypePyxb)
+ if self.max > 1 or self.max == '**' or self.max == float('inf') : self.texteSimple += debTypeSimpleListe
+ self.texteSimple += debTypeSimpleType.format(self.nomDuTypeDeBase)
+ if self.into != None:
+ for val in self.into : self.texteSimple += typeSimpleWithInto.format(val)
+ if self.val_min != float('-inf') : self.texteSimple += minBorneTypeSimple.format(self.val_min)
+ if self.val_max != float('inf') : self.texteSimple += maxBorneTypeSimple.format(self.val_max)
+ if self.max !=1 and self.max != '**' and self.val_max != float('inf') : self.texteSimple += maxLengthTypeSimple.format(self.max)
+ if self.min !=1 and self.val_min != float('-inf') : self.texteSimple += minLengthTypeSimple.format(self.min)
+ self.texteSimple += finTypeSimpleType
+ if self.max > 1 or self.max == '**' or self.max == float('inf'): self.texteSimple += finTypeSimpleListe
+ self.texteSimple += finTypeSimpleNom
+
+
+ #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):
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 = "/>"
# SIMP
-#typeSimple = '\t<simpleType name="{}">\n\t\t<restriction base="{}"/>\n\t</simpleType>\n'
-#debutTypeSimpleWithInto = '\t<simpleType name="{}">\n\t\t<restriction base="{}">\n'
-#typeSimpleWithInto = '\t\t\t<enumeration value="{}"/>\n'
-#finTypeSimpleWithInto = '\t\t</restriction>\n\t</simpleType>\n'
-debutTypeSimple = '\t<simpleType name="{}">\n\t\t<restriction base="{}"'
-finRestriction = "/>"
-finTypeSimple = '>\n\t</simpleType>\n'
-withInto = '\t\t\t<enumeration value="{}"/>\n'
-finWithInto = '\t\t</restriction'
+debTypeSimpleNom = '\t<simpleType name="{}">\n'
+finTypeSimpleNom = '\t</simpleType>\n'
+debTypeSimpleListe = '\t\t<list><simpleType>\n'
+finTypeSimpleListe = '\t\t</simpleType></list>\n'
+debTypeSimpleType = '\t\t<restriction base="{}">\n'
+finTypeSimpleType = '\t\t</restriction>\n'
+maxLengthTypeSimple = '\t\t\t<maxLenght value = "{}" />\n'
+minLengthTypeSimple = '\t\t\t<minLenght value = "{}" />\n'
+maxBorneTypeSimple = '\t\t\t<maxInclusive value = "{}" />\n'
+minBorneTypeSimple = '\t\t\t<minInclusive value = "{}" />\n'
+typeSimpleWithInto = '\t\t\t<enumeration value="{}"/>\n'
eltDsSequence = '\t\t\t<element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
# COMPO
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'
-eltCompoDsSequenceSiProc = '\t\t\t<element name="{}" type="{}:{}" />\n'
# BLOC
debutTypeSubst = '\t<group name="{}"> \n\t\t<sequence>\n'
nomDuCode='monCode'
minOccurs=1
maxOccurs=1
+ nomDuTypePyxb = "T_simulation_title"
+ nomDuTypeDeBase = 'string'
+ into=None
+
+ isListe=False
+ if isListe : texteSimple = debutTypeSimpleListe.format(nomDuTypePyxb, nomDuTypeDeBase)
+ else : texteSimple = debutTypeSimple.format (nomDuTypePyxb, nomDuTypeDeBase)
+ if into != None:
+ texteSimple = self.texteSimple + ">\n"
+ for val in into :
+ texteSimple += withInto.format(val)
+ texteSimple += finWithInto
+ else :
+ texteSimple += fermeBalise
+ texteSimple += finTypeSimple
+
+ #print texteSimple
+ #exit()
+
+ isListe=True
+ if isListe : texteSimple = debutTypeSimpleListe.format(nomDuTypePyxb, nomDuTypeDeBase)
+ else : texteSimple = debutTypeSimple.format (nomDuTypePyxb, nomDuTypeDeBase)
+ if into != None:
+ texteSimple = self.texteSimple + ">\n"
+ for val in into :
+ texteSimple += withInto.format(val)
+ texteSimple += finWithInto
+ else :
+ texteSimple += fermeBalise
+ texteSimple += finTypeSimple
+
+ print texteSimple
+ exit()
texteSimple=typeSimple.format(nomDuType, nomDuTypeBase)
texteElt=eltDsSequence.format(nomElt,nomDuCode,nomDuType,minOccurs,maxOccurs)
eltRacine=eltCata.format(nomDuCode, 'T_'+nomDuCode)
print (texteSimple+texteComplexe+texteCata+eltRacine)
+#typeSimple = '\t<simpleType name="{}">\n\t\t<restriction base="{}"/>\n\t</simpleType>\n'
+#debutTypeSimpleWithInto = '\t<simpleType name="{}">\n\t\t<restriction base="{}">\n'
+#typeSimpleWithInto = '\t\t\t<enumeration value="{}"/>\n'
+#finTypeSimpleWithInto = '\t\t</restriction>\n\t</simpleType>\n'