Sanja,

Thank you for this suggestion.

An example schema would be helpful.

Did you mean something like the following?

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
        <xs:element name="garden" type="gardenType"/>
        <xs:complexType name="gardenType">
            <xs:sequence>
            <xs:element name="climate" type="xs:string"
                fixed="mediterranean"/>
            <xs:element name="tree" type="xs:string"
                minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="vegetable" type="xs:string"
                minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="ornamental" type="xs:string"
                minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
            <xs:attribute name="garden_name" type="xs:string" fixed="MyGarden" 
/>
        </xs:complexType>
    </xs:schema>

So, what should generateDS.py do with that 'fixed' attribute?

1. Initialize the value of that instance member variable to the
   fixed value?  That way, if the attribute is omitted in an XML
   instance document, it would still be initialized to the 'fixed'
   value.

2. On export, only export the attribute when its value is different
   from the fixed value?  Oh, wait, its value must *not* be
   different from the fixed value, right?

3. During build (parsing), check to determine if the value is the
   same as the 'fixed' value.  If not, do what?  Throw an exception?
   Or, merely put out a warning?  Or, should we not check at all,
   and assume that the user has used something like xmllint to
   ensure that those errors are not there?

Or, perhaps the thing to ask is: what should it do differently from
an attribute that has a 'default' value?

And, I suppose that we'd also want to handle the case where 'fixed'
is specified for a member (child with simple type), also, right?
See member "climate" in the above schema.

I'll have to think a bit more.  As you can tell, I'm a bit confused.

I'll look into it.  And, any guidance would be helpful.

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