Re: [Generateds-discuss] Export of an enumerated string restriction attribute with a default value
Brought to you by:
dkuhlman
From: Dave K. <dku...@da...> - 2023-05-17 18:46:28
|
Andrii, I believe there are two possible solutions to this: 1. Add `use="required"` to the attribute declaration in the XML schema. For example: <xs:attribute default="GB" use="required" name="units"> 2. Or, use the command line option "--always-export-default" when you run `generateDS.py`. You will have to figure out which of the two above fits your use case. I have to leave now for a lunch and a walk with a friend, but I'll try to do a little more checking on this later. Hope this helps. Dave Quoting Andrii Iudin <an...@eb...>: > Dear Dave, > > Please could you help with writing out to XML an enumerated string > restriction attribute with a default value? It looks like this: > <xs:attribute default="GB" name="units"> > <xs:simpleType> > <xs:restriction base="xs:string"> > <xs:enumeration value="TB"/> > <xs:enumeration value="GB"/> > <xs:enumeration value="MB"/> > </xs:restriction> > </xs:simpleType> > </xs:attribute> > > When writing out and the value is set to "GB", no units are output > into the XML. > > It appears that the skip is happening in the following generated logic: > def _exportAttributes(self, outfile, level, already_processed, > namespaceprefix_='', name_='datasetSizeType'): > if self.units != "GB" and 'units' not in already_processed: > already_processed.add('units') > outfile.write(' units=%s' % > (self.gds_encode(self.gds_format_string(quote_attrib(self.units), > input_name='units')), )) > > At this point in code already_processed is just an empty set(). > > Is there any switch or change in schema that we might do to ensure > "GB" units are added even if the value is the same as the default one? > > Many thanks and best regards, > Andrii > > > _______________________________________________ > Generateds-discuss mailing list > Gen...@li... > https://lists.sourceforge.net/lists/listinfo/generateds-discuss -- Dave Kuhlman http://www.davekuhlman.org |