Hi Dave, hi group

The only thing i am trying to do is to build XML's on the base of given
schema (using all validation rules that this xsd provides)
then add some custom rules for certain tags etc..

My demo project is here: https://github.com/ryku123/xsd_playground

I have followed instructions on generateDS website but and created objects
(Python 2.7):

#c:\Python27\Scripts\generateDS.py -o "pain001.py" -s "pain001_sub.py"
--super="pain001" pain.001.001.03.ch.02.xsd
or
#c:\Python27\Scripts\generateDS.py -o "pain001_new.py" -s
"pain001_newSub.py" --super="pain001_new" --member-specs="dict"
--export="write etree literal" pain.001.001.03.ch.02.xsd

I guess i am still missing some details that keeps me stucked (i consider
myself as a newbie in this particular area).

I have 2 main problems:

#1.
I can't see validation methods to be generated/applied for particular tags:
i.e:
In schema i've got two similiarly named restrictions:
<xs:element name="Prtry" type="*Max35Text*"/>
<xs:simpleType name="*Max35Text-Swift*">

Second one applies to i.e to tag: *MsgId*

before_name_change:
schema entry: <xs:simpleType name="Max35Text-Swift">

class GroupHeader32_CH(GeneratedsSuper):
    member_data_items_ = {
        'MsgId': MemberSpec_('MsgId', ['Max15NumericText', 'xs:string'], 0),
        'CreDtTm': MemberSpec_('CreDtTm', ['ISODateTime', 'xs:dateTime'],
0),
        'NbOfTxs': MemberSpec_('NbOfTxs', ['Max15NumericText',
'xs:string'], 0),
        'CtrlSum': MemberSpec_('CtrlSum', ['DecimalNumber', 'xs:decimal'],
0),
        'InitgPty': MemberSpec_('InitgPty',
'PartyIdentification32-CH_NameAndId', 0),
        'FwdgAgt': MemberSpec_('FwdgAgt',
'BranchAndFinancialInstitutionIdentification4', 0),
    }
    subclass = None
    superclass = None

    def __init__(self, MsgId=None, CreDtTm=None, NbOfTxs=None,
CtrlSum=None, InitgPty=None, FwdgAgt=None):
        self.original_tagname_ = None
        self.MsgId = MsgId
        if isinstance(CreDtTm, BaseStrType_):
            initvalue_ = datetime_.datetime.strptime(CreDtTm,
'%Y-%m-%dT%H:%M:%S')
        else:
            initvalue_ = CreDtTm
*Result => *missing validation method: "validate_Max35Text_Swift"  (see*
pain001_basic.py*)

after_name_change:
schema entry changed to: <xs:simpleType name="*Max35TextSwift"*> ('-'
removed)

class GroupHeader32_CH(GeneratedsSuper):
    member_data_items_ = {
        'MsgId': MemberSpec_('MsgId', ['Max35TextSwift',
'BasicText-Swift'], 0),
        'CreDtTm': MemberSpec_('CreDtTm', ['ISODateTime', 'xs:dateTime'],
0),
        'NbOfTxs': MemberSpec_('NbOfTxs', ['Max15NumericText',
'xs:string'], 0),
        'CtrlSum': MemberSpec_('CtrlSum', ['DecimalNumber', 'xs:decimal'],
0),
        'InitgPty': MemberSpec_('InitgPty',
'PartyIdentification32-CH_NameAndId', 0),
        'FwdgAgt': MemberSpec_('FwdgAgt',
'BranchAndFinancialInstitutionIdentification4', 0),
    }
    subclass = None
    superclass = None
    def __init__(self, MsgId=None, CreDtTm=None, NbOfTxs=None,
CtrlSum=None, InitgPty=None, FwdgAgt=None):
        self.original_tagname_ = None
        self.MsgId = MsgId
        self.validate_Max35TextSwift(self.MsgId)
        if isinstance(CreDtTm, BaseStrType_):
            initvalue_ = datetime_.datetime.strptime(CreDtTm,
'%Y-%m-%dT%H:%M:%S')
        else:
            initvalue_ = CreDtTm
*Result => *Validation method exists: "self.validate_Max35TextSwift(...)"
(see* pain001_mod.py*)



Then when i run:
grphdr = pain001.GroupHeader32_CHSub()
grphdr.set_MsgId("123aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")

I can type in setter string/int/whatever of any lenght and it won't be
validated.

The same with other tags i.e:
tag: "BICOrBEI"
<xs:element name="BICOrBEI" type="AnyBICIdentifier" minOccurs="0"/>

<xs:simpleType name="AnyBICIdentifier">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}"/>
</xs:restriction>
</xs:simpleType>

This should be validated against "validate_AnyBICIdentifier" and i can put
whatever in set_BICOrBEI() method.


I often run into error in exportChildren method, for example in
'pain001_mod.py' for mentioned tag: *MsgId *i have an error in:

def exportChildren(self, outfile, level, namespace_='',
name_='GroupHeader32-CH', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.MsgId is not None:
            self.MsgId.export(outfile, level, namespace_, name_='MsgId',
pretty_print=pretty_print)
File "C:\xsd_playground\xsd\pain001_mod.py", line 5529, in exportChildren
    self.MsgId.export(outfile, level, namespace_, name_='MsgId',
pretty_print=pretty_print)
AttributeError: 'str' object has no attribute 'export'



#2.

Some tags (a lot) are mapped into somethign like this ('None' objects):

 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Nm':
            obj_ = None
            self.Nm = obj_
            obj_.original_tagname_ = 'Nm'
            # validate type Max70Text
            self.validate_Max70Text(self.Nm)
I have a really hard time figuring out how to make them for example to be
treated as string by default or to apply any other workaround that will
keep validation rules from xsd as well.
I am unable to use "set_Nm()" to fullfill tags that are mapped in this way
(line 28 in main.py)

Whatever I pass to set_Nm() method (string in this case) I get:
....
File "C:\xsd_playground\xsd\pain001.py", line 5678, in exportChildren
    self.Nm.export(outfile, level, namespace_, name_='Nm',
pretty_print=pretty_print)
AttributeError: 'str' object has no attribute 'export'


I would very appreciate any help.


Regards,
Ryku
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to