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
> generateds-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/generateds-users

-- 

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
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to