Sanja, If I understand you correctly, we are getting different results.
I have the following in my test XML schema: <xs:attribute name="garden_name" type="xs:string" fixed="dave's backyard" use="required" /> <xs:attribute name="version" type="xs:token" use="required" fixed="220.127.116.11"/> And, the constructor that is generated by generateDS.py is the following: def __init__(self, garden_name='dave\'s backyard', version='18.104.22.168', vegetable=None): Am I right that this is what you want generated? If so, and if you are not getting that result, is it possible that another version of generateDS.py on your machine is being used by mistake. Or, maybe there is something that I don't understand correctly? I'll send the complete files (schema, generated module, and generateDS.py) in a separate email so as not to put too much bulk in the generateds-users email list. Let me know if there is something else I need to test. About, the generateds-users email list -- Yes, it would be good to reply to or CC that list. For one thing, that gives me an archive of comments, requests, fixes, etc. And, also, there may be other users who are interested, have suggestions, etc. Thanks for help with this. Dave On Mon, Feb 19, 2018 at 12:30:20PM +0000, Sanja Abbott wrote: > Dear Dave, > > thank you for sending me the fix for the issue of 'fixed values for > attributes'. I've tested your solution and it seems it's not producing the > result I expected. > > I'd like to have this attribute: > <xs:attribute name="version" type="xs:token" use="required" > fixed="22.214.171.124"/> > > For my purpose it's essential that the attribute is 'required'. If I remove > use="required" and set default="126.96.36.199" (default can't be required): > <xs:attribute name="version" type="xs:token" default="188.8.131.52"/> > > I get exactly what I need in the python script using generateDS.py: > > def __init__(self, emdb_id=None, version='184.108.40.206', admin=None, > crossreferences=None, sample=None, ... > > However, the attribute I require creates: > def __init__(self, emdb_id=None, version=None, admin=None, > crossreferences=None, sample=None, ... > > > Is there anything that can be done so that I can use the intended format for > my attribute. > > Since it's my first time contacting you I wasn't sure if I should cc > generateds-users as well. Please let me know. > > Thank you for your help, > Sanja > > > On 15/02/2018 21:20, Dave Kuhlman wrote: > > Sanja, > > > > I've been thinking about this issue a bit more. > > > > From what I can learn, an attribute with a `fixed` value is the same > > as one with a `default` value except that a validating parser should > > enforce the `fixed` restriction. That means that if the value of > > that attribute is different from the value specified by `fixed` in > > the schema, then the parser should report that the XML document does > > not validate. > > > > Here is a bit of information, if you are interested: > > > > - https://www.w3schools.com/xml/el_attribute.asp > > > > - https://msdn.microsoft.com/en-us/library/ms256143(v=vs.110).aspx > > > > The parsers generated by generateDS.py are *not* validating parsers. > > So, I believe that we're good by treating `fixed` attributes in the > > same way as `default` attributes. > > > > With this change, you will be able to get that fixed value even > > when the XML instance document omits it. > > > > If the user (you, for example) wants to validate an XML instance > > document and wants to enforce the `fixed` restriction, then s/he can > > run `xmllint` (or some other XML validation program) against the XML > > document and the schema. > > > > I've attached a modified version of generateDS.py containing this > > fix to a separate email. > > > > Let me know what you think and whether this solves the problem for > > you. > > > > And, thank you for suggesting this enhancement. > > > > Dave > > > > On Fri, Feb 09, 2018 at 11:42:22AM +0000, Sanja Abbott wrote: > > > Hi, > > > > > > I wonder if you could implement 'fixed' values for attributes in your > > > generateDS. My schema has an attribute called 'version': > > > > > > However, the python script that generateDS creates has no means to use > > > this > > > fixed value. > > > > > > Thank you, > > > Sanja Abbott > > > > > > -- > > > _____________________________________________ > > > > > > Sanja Abbott, PhD > > > Bioinformatician and Software Infrastructure Manager > > > Cellular Structures and 3D Bioimaging > > > European Bioinformatics Institute > > > Welcome Trust Genome Campus > > > Hinxton > > > Cambridge > > > CB10 1SD > > > UK > > > http://www.ebi.ac.uk > > > Tel: 01223 49 4300 > > > > > > ------------------------------------------------------------------------------ > > > Check out the vibrant tech community on one of the world's most > > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > _______________________________________________ > > > generateds-users mailing list > > > email@example.com > > > https://lists.sourceforge.net/lists/listinfo/generateds-users > > -- > _____________________________________________ > > Sanja Abbott, PhD > Bioinformatician and Software Infrastructure Manager > Cellular Structures and 3D Bioimaging > European Bioinformatics Institute > Welcome Trust Genome Campus > Hinxton > Cambridge > CB10 1SD > UK > http://www.ebi.ac.uk > Tel: 01223 49 4300 > -- Dave Kuhlman http://www.davekuhlman.org ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ generateds-users mailing list firstname.lastname@example.org https://lists.sourceforge.net/lists/listinfo/generateds-users