-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathREADME
1252 lines (1094 loc) · 54.7 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
================================================
generateDS.py -- Generate Python Data Structures
================================================
----------
What is it
----------
generateDS.py generates Python data structures from an Xschema
document. It generates a file containing: (1) a Python class for
each element definition and (2) parsers (which use the Python
minidom module) for XML documents that satisfy the Xschema
document. The class definitions contain:
- A constructor with initializers for member variables.
- Get and set methods for member variables.
- A 'build' method used during parsing to populate and instance.
- An 'export' method that will re-create the XML element in an XML
document.
- An 'exportLiteral' method that will write out a text (literal)
Python data structure that represents the content of the XML
document.
---------------------------
How to build and install it
---------------------------
De-compress the generateDS distribution file. Use something like
the following:
tar xzvf generateDS-1.5a.tar.gz
Then, the regular Distutils commands should work:
python setup.py build
python setup.py install
-------------
How to use it
-------------
See generateDS.html for documentation.
Produce class definitions and sub-class definitions with something
like the following:
$ python generateDS.py -o people.py -s people_subs.py people.xsd
Here is a test using the enclosed sample Xschema file:
$ python generateDS.py -o people.py people.xsd
$ python people.py people.xml
----------------
More information
----------------
More information on generateDS.py is in generateDS.html
in the distribution or
`generateDS -- Generate Data Structures from XML Schema --
http://www.rexx.com/~dkuhlman/generateDS.html
<http://www.rexx.com/~dkuhlman/generateDS.html>`_.
There is also a tutorial. See tutorial/tutorial.html
in the distribution or
`generateDS -- Introduction and Tutorial --
http://www.rexx.com/~dkuhlman/generateds_tutorial.html
<http://www.rexx.com/~dkuhlman/generateds_tutorial.html>`_.
-----------
Limitations
-----------
XML Schema limitations -- There are lots of things in Xschema that
are not supported. You will have to use a restricted sub-set of
Xschema to define your data structures. See the documentation
(generateDS.html) for supported features. See people.xsd and
people.xml for examples.
Mixed content -- generateDS.py generates a parser and data
structures that do not handle or represent mixed content. Here is
an example of mixed content:
<note>This is a <bold>nice</bold> comment.</note>
My only, and some what feeble, excuse for this is that
generateDS.py is intended for structured data rather than marked
up text. However, whether my excuse is a good one or a feeble
one, you should be warned that if you anticipate needing mixed
text, do *not* use generateDS.py.
Large documents -- The parser generated by generateDS.py uses
minidom. This means that the entire XML document must be read and
a DOM tree constructed in memory. In addition, the data
structures generated by generateDS.py must occupy memory. This
means that generateDS.py is not well-suited for applications that
read large XML documents, although what "large" means depends on
your hardware. Notice that the parsing functions (parse() and
parseString()) over-write the variable doc so as to enable Python
to reclaim the space occupied by the DOM tree, which may help
alleviate the memory problem to some extent.
-------
License
-------
Copyright (c) 2002 Dave Kuhlman
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[MIT License -- http://www.opensource.org/licenses/mit-license.php]
--------------
Change history
--------------
Version 2.7c (08/06/2012)
* Added xs:hexBinary to the list of string types in generateDS.py
and django/generatedssuper.py. Effectively, we are generating
the same code for types xs:base64Binary and xs:hexBinary. That
leaves it up to the user to add code that converts into and out
of these formats. Thanks to Peter Kreinhöfer for finding this.
* Added support for compressed export, that is, export without
ignorable white space (indentation and new lines). Normally the
generated export methods produce pretty-printed (indented) XML
output. With this change, we generate modules which enable you
to export in a way that omits ignorable whitespace. It is
anticipated that this feature will be useful to those who need
to export XML documents that are machine readable but not human
readable. Thanks much to Logan Owen for doing the work on this
one. Compressed (non-pretty-print) output is produced by
passing the keyword argument pretty_print=False to the export
method. There is a note in the document (generateDS.html) about
it; see section titled "Exporting compact XML documents".
Version 2.7b (12/10/2011)
* Fix for xs:any in buildChildren in an element defined with no
other children so that we do not generate "else:" clause without
an "if ...:". Thanks to Keith Robertson for help with this.
* Change for xs:any in buildChildren (when maxOccurs > 1) so that
the gds_build_any() method always, consistently takes a single
*child* node as input and returns a single built object. Thanks
Marcin Tustin for guidance with this.
* Fix for element definition containing an anonymous
xs:simpleType.
* Added xs:time to list of handled simple (date, time) types.
Version 2.7a (11/04/2011)
* Fix for case where a child is defined with a reference (ref="")
to a complexType (rather than a simpleType) and the complexType
is abstract.
* Added minimal support for xs:any. See section "Support for
xs:any" in the documentation.
* Added unit test for xs:any.
Version 2.6b (10/13/2011)
* Fix for case where a child element is declared with a type that
is a simpleType whose restriction base is another simpleType
that is referred to with a namespace prefix. With this fix we
ignore the prefix, so that at least it will work when there are
*not* two different simpleTypes whose qualified names have the
same local name (qualified name minus the namespace prefix).
Thanks to Thomas Nichols for finding and reporting this one.
* Added a unit test for the above restriction base with namespace
prefix.
* Added a blank character when needed at the beginning and end of
of doc strings inserted in generated classes to protect against
the case where the doc string begins or ends with a double quote
character.
* Fixes to various files in the tutorial/Code/ directory and to
the text files in the tutorial/ directory in order to make them
more consistent and less confusing. Added the individual sample
code files to the distribution so that users will not have to
find and unzip a zipped archive.
* Fixes to files in tests/ and to the distribution config
(MANIFEST.in) so that the distributed version would pass unit
tests. (Please let me know if it does not.)
* Removed file generatedssuper.py from the distribution. Added
notes to the documentation on how to create this module by
copying from a generated module for those who want to customize
those methods in the common superclass.
* Fix to django/generatedssuper.py -- Regularized and fixed the
names generated in models and forms files.
* Fix to the code that generates the member_data_item_/MemberSpec_
list/dict. If the type of a child element is defined by a
reference (ref="") to an element rather than, e.g. a
complexType, it was using the child's name not it's type.
* Added xs:base64Binary and xs:language to the list of string
types in generateDS.py and django/generatedssuper.py. Also,
xs:anyURI and xs:duration.
Version 2.6a (07/28/2011)
* Fix to capture xs:/xsd:/etc namespace prefix from schema. Was
not setting global variable XsdNameSpace. Thanks to Frank Liauw
for focusing my attention on this one.
* Fix for substitutionGroup -- Was not setting the correct
instance variable during generation of build method when child
is a member of substitutionGroup. Thanks to Serge Dikic for
finding this one and bringing it to my attention.
* One more attempt to fix whether to call the exportChildren
method when the complexType is an extension and not a
restriction and not defined with simple content that extends a
simpleType. Thanks to Jaime Cepas for alerting me to this.
* process_includes.py has a fix to the problem where there are
more than one anonymous complexType that define elements with
the same name. The issue is that generateDS.py must generate a
Python class for each complexType and cannot do so in this case.
One solution, which is now implemented in process_includes.py,
is to raise each complexType to top level in the schema DOM tree
and to give it a name. process_includes.py does this by
appending "Type" to the name, and when there are duplicate
names, appending "1" or "2" or ... to that.
So far this change passes my tests, but it does not work for
you, then comment out the call to raise_anon_complextypes().
Thanks to Amal Khailtash for finding a schema that exhibits this
problem and bringing it to my attention.
* Fix for generation of export method that exports xs:anyAttribute
when there is an xsi:type attribute.
* Fix for use of valueOf_ -- Should only be used when element is
defined either with (1) mixed content or (2) simpleContent.
* Question: The xsi:type attribute is being exported for any
derived type. Perhaps it's harmless, but it seems excessive.
When should the export method have that code to export the
xsi:type attribute? Only for types derived from (an extension
of) an *abstract* base type? Only for the abstract base type
itself? Only when a derived type is substituted for a base type
using the base type's tag and the xsi:type attribute to specify
the derived type? Need to investigate.
* I've reworked the xsi:type attribute stuff. It now operates on
the following assumptions: (1) an instance of any complexType
that has been extended can have an xsi:type attribute (which
specifies one of the extending types) and (2) the generated code
should export the xsi:type attribute only and always when (if
and only if) the element in the input instance document has that
attribute.
* A patch to convert floats and ints etc to str during export.
Thanks Jaime Cepas.
* Fixes to ctor/initializers when there is a default value for a
an child element defined as a complexType containing
simpleContent.
* librarytemplate -- (1) Renamed documentation files to
librarytemplate_howto.html and librarytemplate_howto.txt for
consistency with the name of the librarytemplate distribution
file (currently librarytemplate-1.0a.zip). (2) Added the
documentation and distribution files for librarytemplate to the
main generateDS distribution file.
* Added xs:byte to the list of integer types.
Version 2.5a (06/06/2011)
* Fix for generation of default value in parameters for the
constructors.
* Fix for lookup of attribute value in generated buildAttributes
methods -- Formerly, attribute names having a namespace prefix
were not being found.
* Added some support for xs:group -- Named model groups (model
group definitions) are now treated as definitions of blocks of
elements to be copied/inserted where referred to. This
replacement has been added to the preprocessing done in
process_includes.py. So, this <xs:group ref="some_def"/> is
replaced by the contents of <xs:group name="some_def"> ...
* Fix to generation of calls to validator methods for child
elements. Before the fix, the validators were called in
buildAttributes methods but not in buildChildren. Also,
generation of the validator method (stubs) was also missing in
some cases. Thanks to Béres Botond for alerting me to this.
* Fixes to generateds_gui.py -- Now it can load a session again.
Also a fix to the check for and warnings about the changes to
current session on exit.
* process_includes.py -- Fix for yet another problem with
including the same file multiple times when included from
different directories.
Version 2.4c (03/21/2011)
* Added minimal support for unsignedLong, unsignedInt, and
unsignedByte.
* Made the retrieval of the parent (superclass) name and parent
object for an element more consistent. Fixed some cases where
this was not handled correctly, in particular, the generation of
arguments and paramenters for ctors (__init__) was inconsistent
and caused errors.
* Regularized the handling of fromsubclass_ and added this
handling to the exportChildren methods. This is used to tell a
superclass, during build and export, that the subclass has
already performed certain operations.
* Fix to process_includes.py so as to prevent it from loading
schemas multiple times. The check for already_processed was
formerly incorrect.
* Fix related to restrictions on complexType -- Do not generate
call buildChildren in the superclass for restrictions (as
opposed to extensions) of a complexType. Ditto for
exportChildren. Note that restrictions must repeat (and
restrict the value of) each sub-element that is to be included
in the content of the restriction. See:
http://www.w3.org/TR/2004/REC-xmlschema-0-20041028/#DerivByRestrict
Version 2.4b (02/21/2011)
* Fix to generation the superclass in the class statement header
line. Formerly we did not correctly pick-up the superclass
name (from extension base=""). Thanks to Timo Sugliani for
finding this bug.
Version 2.4a (02/16/2011)
* A few fixes to format of some error messages.
* Clean-up names in the exportableClassList (__all__).
* Modify reading session object/doc to use lxml instead of
minidom.
* Fix to process_includes.py to protect against crash when an
import element is missing a schemaLocation attribute.
* Fix to parsing and exporting simpleTypes declared as lists
(<xs:list>).
* Added new methods to class GeneratedsSuper to validate (during
build) and format (during export) for simpleTypes declared as lists
(<xs:list>).
* Fix for incorrect detection of type during generation of build
method.
* Added first cut at generating Django models and forms.
Thanks to Derek Corbett for this suggestion.
* Added "meta-app" that generates Django database models and
Django forms. See doc and files in subdirectory django/.
* Fix to generation of __all__ list: converted non-word
characters to "_" etc
* Fix to process_includes.py so that it uses the entire path to a
file when trying to determine whether it duplicates a previous
import. Perhaps this will avoid skipping an import when
attempting to import two files with the same name from
different directories. Thanks to Mihai Ibanescu for pointing
out this fix.
Version 2.3b (12/28/2010)
* Fix for simpleTypes defined as a restriction whose (ultimate)
base type is a pre-defined simple type which were not generating
correct (type-specific) code in build method. Thanks to
Noel Merket for finding this problem.
* Fix for simpleTypes defined as a xs:list with "itemType"
attribute where the type was not being recognized.
* Fix so that we recognize some other simple types as xs:string
type (e.g. xs:NMTOKEN, xs:ID, xs:Name).
* To do:
- If a simpleType is a restriction on another simpleType and
the base simpleType definition is declared as a list, we are
not recognizing that it is a list.
Version 2.3a (12/02/2010)
* Added generatation of code to handle attributes inherited by a
restriction from its base type and the types that the base
extends (i.e. from a restriction base class and its
superclasses). Thanks for help from Jaime Cepas.
* Fix to code that generate the references to the superclass from
a type that is an extension: special characters (e.g. dash)
were not being cleaned/mapped. Reported by Koen Smets; thanks.
* To do:
- In a restriction, inherited attributes can be "prohibited".
It would be nice if gDS would do something to block their
use.
- When:
AbstractElement mixed=false and
Element1 mixed=true base=AbstractElement and
Element2 mixed=FALSE base=AbstractElement
Incorrect parse code is generated for Element2.
Reported by Jaime Cepas.
- It might be desirable if the getter functions could be asked
to return values encoded to utf-8 for xs:string types.
- Code that is generated to export to python code needs
updating, in particular we need to update encoding of
exported strings. Thanks to Kristoffer Kobosko for
reporting this.
- Update to the code that generates code that exports Python
literals (exportLiteral ...). In particular: (1) fix
excoding of Python code and of string literals (unicode, utf-8).
Version 2.2b (11/10/2010)
* Added generation of __all__ global variable containing a list
of generated class names. This enables you to do a reasonably
safe "from mymodule import *. It's sorted, so it also gives
you something in the way of an alphabetical table of contents
of the generated classes. Thanks to Jaime Cepas for this.
* Added another fix so that the generated code for mixed content
elements will not generate empty blank lines on export. Thanks
again to Jaime for this fix.
* Added patch to sort mixed content in their class containers.
Jaime contributed this one too. Thanks again.
* Added check for endless recursion while collection list of
parent type element names. When detected, raises exception
that identifies the elements. Thanks to Maximilian Holtzberg
for finding this one. One case that can cause this problem is
when an element type definition extends a type definition of
the same name in a different namespace. Since generateDS.py
ignores the namespace, this looks like a type that is extending
itself.
* Modified code generated to process token lists in order to
prevent breakage processing some strings.
* Updated the tutorial so that the examples use the new parsers
(ElementTree or lxml).
* The "Clear" buttons in generateds_gui.py is broken when run with
GTK2. generateds_gui.py is still usable, but, if you need to
erase the contents of a text field, you will have to do so
manually until I can figure out a fix.
Version 2.2a (9/14/2010)
* Changes for coding consistency -- Used wrt() pervasively
instead of outfile.write().
* Re-write of process_includes.py -- It now handles
xs:include/xs:import elements that include a file from another
directory that incude a file relative to that directory that
include a file across HTTP, and so on.
* The command line option --search-path is no longer supported. I
don't think that behavior was standard for XML schema anyway.
Removed support for search_path from generateDS.py,
process_includes.py, and generateds_gui.py.
* Added support for specifying additional name mappings in a config
file: generateds_config.py. That file, if it exists, must be
located where it can be imported by generateDS.py and should
contain a dictionary named NameTable. For example, the following
maps the name "range" to "rangeType" so that if the schema defines
a complexType "range", generateDS.py will generate a class named
"rangeType":
NameTable = {
'range': 'rangeType',
}
See the doc for more on this.
* Instead of using the lower() function from the string module,
added a function to the GeneratedsSuper class and used the string
method. Prepares for Python 3.0
* Added "gds_" prefix to all methods in class GeneratedsSuper to
make possible name clashes less likely.
* Fixes to exporting elements with mixed="true" -- Reduced extra
whitespace.
* Fixes to building (capturing) attribute values for elements with
anyAttribute="..." -- Eliminated capture of duplicate attribute
values.
Version 2.1d (8/23/2010)
* Fix to indentation of generated code in the build method for
type checking of NonNegativeIntegerType.
* Fix to generation parameters in call to superclass constructor.
Count of children was incorrect, triggering generation of
valueOf_.
* Known issue -- If type B extends type A, and type A declares
anyAttribute, then duplicate attributes with the same name may
be produced during export.
* Known issue -- Some namespaces ("{URI}") are not converted to
namespace prefix during export. The needed information is not
available during export.
Version 2.1c (8/8/2010)
* Fix to functions parse, parseString, and parseLiteral so that
they start the build with the correct root class. I believe
that there yet is another case that this does not handle,
specifically when element name is different from class/type
name and the element definition is not the first definition in
the schema.
* Fix to generation of build method for derived elements (i.e.
elements with "extension base=". These were being treated as
if they were abstract, i.e. 'abstract="true"'.
* Fix to generation of the call to the superclass constructor in
the generated subclass module. Prevented the generation of
duplicate arguments.
* Added a comment to the generated superclass module at the top
that specifies the utf-8 source code encoding:
# -*- coding: utf-8 -*-
Version 2.1b (8/2/2010)
* Fix to generation of export functions. If no children, must
generate "pass" statement.
* Changed generated get_all_text function so that it uses an "if"
statement instead of a conditional (if) expression. The
conditional expression does not work with older versions of
Python.
Version 2.1a (7/8/2010)
* Added ability to capture annotation/documentation element text
as doc-strings in the generated classes. Thanks to
Roy Williams for suggesting this and for guidance.
Version 2.0b (6/24/2010)
* Fix to generation of export method so that valueOf_ is exported
when childCount == 0 and not isMixed.
Version 2.0a (6/21/2010)
* Switched to use of lxml/ElementTree in generated files.
Thanks to Biswanath Patel and Jaime Huerta Cepas for
encouraging me to implement the switch to lxml/ElementTree.
* Modified the generation of functions parse(), parseString(),
and parseLiteral() so that they automatically recognize the
root element of an instance XML document and call the build
method of the appropriate class.
* Fix to hasContent_ method so that so that in elements defined
with extension-base, the superclass is checked also.
* For classes that must call an overridden method m in the
superclass, switched to use "super(superclassname, self).m(...)"
instead of "m.(self, ...)".
* Known issues -- (1) generateDS.py loops and crashes with
"RuntimeError: maximum recursion depth exceeded" on some
schemas (for example collada_schema_1_4.xsd). (2) Failure in
process_includes.py with import of remote file and nested
imports (for example collada_schema_1_5.xsd).
Version 1.20g (5/21/2010)
* Update to documentation -- Added a section on suggested ways to
handle/recognize different top level (root) elements.
Version 1.20f (5/3/2010)
* Fix to generation of export so that anyAttribute does not cause
duplicate attributes to be exported.
* Fix so that we do a better job of determining whether a
reference to a type is a simple, builtin type in generation of
constructor.
* Fix to generation of constructors so that (1) valueOf_ is
intialized in subclass modules and (2) valueOf_ is initialized
to None (rather than '').
To do: Extend the --root-element flag so that we can specify both
the tag name and the element/type name. Sometimes they are
different.
Version 1.20e (2/8/2010)
* Fixed error that caused incorrect tag name to be exported
when the tag name contains special characters and the tag name is
different from the type name.
* Fixed links so that latest versions are included in the install
distribution file.
Version 1.20d (2/3/2010)
* Updated version number/info in genereateds_gui.py.
* Fix to process_includes.py -- Handle include elements and
import elements in the same way. In particular, allow both to
reference schema files on either the local file system or
remotely across the Net (via ftp or http).
* Fix to generation of properties -- When the name of a member is
mapped (e.g. a Python language keyword), wrong name for getter
and setter was used.
* Fix to generation of export methods: missing encoding.
* Fix to selection of type for exportLiteral.
* Added missing files in the tests/ directory to the distribution.
Version 1.20c (1/1/2010)
* Replaced symbolic links in the distribution with hard links.
Symbolic links do not work on MS Windows.
* Fix to the use of the subprocess module in generateds_gui.py,
which had caused a problem on MS Windows.
* Cosmetic fix in generateds_gui.py: labeled "Save" (session) button.
* Fix so that File/Open action in generateds_gui.py will check
for and warn user if the session data has been modified.
* Fix to generation of code for simpleContent with restriction:
now treats the restriction element as a superclass. Thanks
to Franis Sirkovic for catching this and for providing the
patch. Also added a unit test for this case.
Version 1.20b (12/14/2009)
* Fix to process_includes.py so that it handles relative paths
in include/import elements in the schema.
* Various fixes and additions to the GUI front-end, e.g. added
"Clear" buttons to erase some fields.
* Fixed bug -- self.inRestrictionType was not initialized.
* Added --session command line option to generateDS.py -- It
can now use session files generated by the GUI front-end.
* Fixes to the generation of the exportLiteral methods. We can
now export Python literal representation of an instance doc
that can be read/imported by Python.
* Added unit test for generation of Python literal representation.
* With the help of Erica Tolbert, generateDS.py can now generate
bindings for gcdml (Genomic Contextual Data Markup Language.
See http://gensc.org). Thank you, Erica.
* generateDS.py can now generate bindings for the following
(rather large) schemas:
- gcdml -- Genomic Contextual Data Markup Language --
See http://gensc.org
- Collada -- 3D Asset Exchange Schema 1.5 -- See
http://www.khronos.org/collada/
- Vcloud --Cloud computing -- See
http://www.vmware.com/solutions/cloud-computing/vcloud.html
- FpML -- Financial products Markup Language -- See
http://www.fpml.org/
Version 1.20a (12/01/2009)
* Added first version of the GUI front-end. See the generateDS
doc (generateDS.html).
Version 1.19a (10/21/2009)
* Enhancement to the table of information generated in each class
when the --member-specs=list|dict command line option is used.
For a complexType defined as a simpleType, we now generate a
list of the simpleType and the simpleTypes it is based on using
name "valueOf_". Thanks to Ryan Leslie for much help and
guidance with these changes.
Example:
'valueOf_': MemberSpec_('valueOf_', [u'RelationType',
u'RelationType2', u'xs:string'], 0),
Note the following incompatible changes:
- _MemberSpec changed to MemberSpec_ -- We want avoid posible
name conflicts, not make it "weakly hidden". See the Python
style guide for more on this
- _member_data_items changed to member_data_items_ -- Same
reason.
- Method MemberSpec_.get_data_type() now returns the last item
if the types is a list and the single type if not a list.
- Method MemberSpec_.get_data_type_chain() is a new method that
returns the entire list of data types.
The new tutorial (see tutorial/tutorial.html in the
distribution) has an example of the use of the MemberSpec
feature.
* Fix to DecimalType -- In some cases treated as an integer.
Should be a float. Thanks Ryan Leslie for catching this.
* Removed last bits of the generation of a SAX parser. It no
longer worked and is not needed.
* Several fixes to determination and handling of types.
* Added unit test for extensions to simple types and for MemberSpec.
* There is now a preliminary version of a tutorial.
Version 1.18f (9/14/2009)
* Fixes to process_includes.py from Mihai Ibanescu. These fixes
address namespace and namespace prefix problems for XML tree
that is copied into a document. Thanks Mihai.
* Added xs:anySimpleType to the list of OtherSimpleTypes. This
prevents anySimpleType from being used as a base type.
* Change so that sub-classes are generated for types that do not
have children or attributes.
* Fixed crash that occurred when a simple type is nested in a simple
type and use of memberTypes attribute.
* Fix to GeneratedsSuper -- Inherit from "object".
* Added command line option --no-versions,
which, when used, tells generateDS.py not to insert the
version in generated files. This is useful when you want to
be able to compare generated files and not detect version
differences.
* Patch to eliminate extra space after element tag. Thank you
Ryan Leslie.
Version 1.18e (9/1/2009)
* Added patch from Mihai Ibanescu which handles and expands
groups. Also added Mihai's unit test for groups. Thank you,
Mihai.
* Added patch, also from Mihai, that passes the node's text to
the super-class constructor.
* Added patch that implements a --no-dates command line flag
which, when used, tells generateDS.py not to insert the
time-stamp in generated files. This is useful when you want to
be able to compare generated files and not detect date/time
differences. Thanks again to Mihai.
Version 1.18d (8/26/2009)
* Automatic detection of the namespace prefix used in the schema
document. Thanks to Mihai Ibanescu for this enhancement.
* Fix to deal conflicts with generateDS's internal function
names, for example "build". Thanks again to Mihai.
* Upgrade to the unit test harness. Replace popen (which is
deprecated) with use of the subprocess module. Thank you Mahai.
* Fix in the class constructors (__init__) to cast XML primitive
types (xs:integer, xs:float, etc) to Python built-in types
(int, float, etc). Thanks once more to Mahai.
* Fix to add enumeration value resolution when the possible
values are not declared in an explicit definition but in a "top
level" type. Also fix a bug with enumeration value population
for elements where the unwound element stack contains more than
one element. Thanks to Chris Allan for this fix.
Version 1.18c (8/11/2009)
* Small changes related to check for mixed content.
* Enhancement to generation of hasContent_() method to check for items
with maxOccurs > 1.
* Fix for generation of test for valueOf_ in hasContent() method.
* Fix for generation of initializers in ctor -- children were being
skipped when the element is mixed.
Version 1.18b (7/29/2009)
* Fix for exception with simpleType that is an extension of
another simpleType.
* Change to mixed extension chain -- Will now generate class.
* Fix to generation of constructors -- Will now initialize to
default value for simpleTypes.
* Fixed generations of validator methods, validator bodies,
and call to validator bodies for attributes.
* Command line option "--validator-bodies" now triggers check for
option value is an existing directory.
* Various cleanup, deleting commented-out debug code, etc.
* Now writing help messages, error messages to stderr instead of
to stdout.
Version 1.18a (7/14/2009)
* Added command line flag --member-specs to generate the member
specifications as described in "User Methods" section of the doc.
The member specs can be a list or a dictionary.
* Fix to export indentation. Thanks Tim Marchelli.
* Added a utility script: generate_coverage.py which generates a
dictionary of class names and classes from a (superclass) module
generated by generateDS.py.
Version 1.17d (7/2/2009)
* Fix for generation of recursively defined simpleTypes, e.g.
a simpleType defined as a restriction of another simpleType.
(see fix_simpletype comment in generateDS.py)
* Added version number to generated class files.
* Fixes to/for process_includes.py -- DirPath/DIRPATH now initialized
correctly and fixed failure to initialize a local variable.
Version 1.17c (6/24/2009)
* Fix for error generating code for exporting related to
simpleType.
* Fix for syntax error in export of boolean types.
* Fix for export of elements with type of attribute defined
in-line.
* Fix to generation of export function when the --silence
command line option is used.
Version 1.17b (6/10/2009)
* Fix so that generateDS.py will still work with Python 2.4.
Thanks to Dave Sugar for that.
Version 1.17a (5/20/2009)
* Modified export of children of type xs:string so that
(1) if None, not exported and (2) if not None but an
empty string, exported (example "<aa></aa>").
* Generated calls to format_string(), format_integer(), etc
in the generated export methods. Enables the user to
override these methods to customize format of exported
values. See the "Overridable methods" section in the
doc (generateDS.html) for more info and for an
explanation of how to override these methods.
Currently used to give the user control over formatting
of values during export.
* Fixes to generated build and export methods so that
elements defined as xs:simpleType as handled as
the specificsimpleType xs:restriction base, for example
xs:string, xs:integer, etc.
Version 1.16e (4/28/2009)
* Eliminated generation of SAX parser. I'm sure it no longer
worked, anyway.
* Fix to export of CDATA characters, provided by Kerim Mansour.
Thanks.
* Added support for command line option --external-encoding.
Exported character data is now encoded to sys.getdefaultencoding()
or to the encoding specified by command line option
--external-encoding.
* Added attributes (in addition to children) to the list of
data type specifications in _MemberSpec/_member_data_items.
This fix was provided by Ryan.
* Several fixes suggested by Kerim Mansour including one related
to export of CDATA. Thank you Kerim.
* Removed generation of SAX parser. It did not work
any more anyway.
Version 1.16d (3/25/2009)
* Fixes to generation of the exportLiteral functions. We
can now do exportLiteral, then import the resulting file
in Python. See generated parseLiteral() for an example.
* Added an additional parameter to the export_xml() methods.
Now, you can call export_xml() as follows:
rootObj.export_xml(outfile, 0,
namespacedef_='xmlns:abc="http://www.abc.com/namespacelo"')
which will insert the namespace prefix definition in the
exported root element.
* Added new command line option --namespacedef= to specify
the namespacedef_ to be passed in by the generated
parse() and parseString() functions. Example use:
generateDS.py --namespacedef='xmlns:abc="http://www.abc.com/"'
-o out.py myschema.xsd
Version 1.16c (3/13/2009)
* One more fix for abstract types -- When the implementation
element/class for an abstract class exports itself, it adds
the xsi:type="class_name" attribute.
* A minor fix to handling namespace prefix and the -a command
line option.
* Additional fixes so that in constructors (__init__), all
instance variables are initialized to None.
* Some fixes to quoting and escaping quotes when exporting
attribute values. Thanks to Kerim Mansour for help with this.
Version 1.16b (3/9/2009)
* Added support for restriction/list, i.e. a list of words
separated by whitespace.
Version 1.16a (2/16/2009)
* Generated export methods now check for empty content and
write out <xx ... /> rather than <xx ...></xx> if empty.
* All generated constructors (__init__()) now initialize
instance variables to None.
* Generated export methods now check for None before attempting
to write out attributes and children.
* More consistent use of direct access to instance variables
rather than calling getter methods with a class, that is
use of self.xxx rather than self.get_xxx().
Version 1.15d (1/22/2009)
* Fix to setup.py so that it also installs process_includes.py.
* Enhancements to process_includes.py so that it can also
retrieve included files via ftp and http.
* Fixes for default values for attributes.
* The above changes are all from Arne Grimstrup. Thank you Arne.
Version 1.15c (11/26/2008)
* Added switch (--silence) to cause generateDS.py to generate
parsing functions that do not write output to stdout. This fix
contributed by Al Niessner.
Version 1.15b (11/24/2008)
* Added Amnon Janiv's fixes for attribute groups and for logging.
Version 1.15a (11/20/2008)
* Added support for abstract elements/types. See:
http://www.w3.org/TR/xmlschema-0/#abstract
Thanks to Luigi Paioro for help with this.
Version 1.14g (10/17/2008)
* Fix in generation of exportChildren (omitted "_" in "namespace".
Version 1.14f (10/06/2008)
* Minor fix related to simple types in generateBuildStandard_1().
Version 1.14e (09/25/2008)
* Minor fix for generation of syntax error (missing parenthesis).
* Eliminated generation of specification of superclass
(superclass =) for undefined types.
* Fixed error setting value in SimpleElementDict.
* Fixed error when getting type for building attributes.
* Fixed and regularized exception reporting when building float
and integer values.
* Fixed error referring to simple types in build function.
Version 1.14d (08/28/2008)
* Several fixes related to simple types.
Version 1.14c (08/16/2008)
* One more namespace patch from Andre Adrian.
* A fix to generated export methods for valueOf from Oscar (Oeg
Bizz).
* First attempt to fix the name_type problem, specifically an
incorrect generation of the element name where it should
generate the type name and vice versa.
Version 1.14b (06/17/2008):
* More namespace patches from Andre Adrian.
* Changed "lower()" to "str_lower()" in generated code so that
we have a less common name in generated code.
Version 1.14a (06/03/2008):
* In generateBuildFn, the generated code formerly would skip the
children of a base class in an extension class if the
extension class has children of its own. This patch fixes
that problem. (The buildChildren call for the base class is
inside a "if hasChildren == 0" block.)
* The export functions formerly would output the attributes and
children of the derived classes before those of the base
class, where the XSL spec specifies that the base class
elements are earlier than derived elements in a sequence. This
patch corrects the generation order.
* This patch adds proper xs:boolean reading and writing to
generateDS. "true" and "false" values in the XML will become
True and False in Python, and will be written back out as
"true" and "false", respectively.
Version 1.13a (05/26/2008):
* Added support for generating namespace prefix during export
if the XML Schema specifies the targetNamespace. Thanks to
Andre Adrian for implementing this feature.
Version 1.12b (05/20/2008):
* Patches to escape special XML characters (entities) in valueOf
and attributes. Thanks to Darius Powell for this fix.
Version 1.12a (05/06/2008):
* Fix to name used to generate validation method.
* Embedded process_includes.py functionality into generateDS.py.
Version 1.11d (04/28/2008)
* Added support for specifying default values in attributes
and elements that are primitive types.
Version 1.11c (03/31/2008)
* A fix in enumeration building code.
Version 1.11b (11/19/2007)
* Fixed bug that caused an infinite loop when a class has a
simple type as a base/super class.
* Added additional simple types to the list of recognized simple
types. For a list of simple types, see:
http://www.w3.org/TR/xmlschema-0/#SimpleTypeFacets
* Added additional Python keywords to list of transformed names.
See global variable NameTable.
Version 1.11a (10/11/2007)
* Various added features contributed by Chris Allan. For more
information see:
http://www.rexx.com/~dkuhlman/generateDS.html#additional-features
Version 1.10a (08/21/2007, again)
* Added xs:int basic type. Handle same as xs:integer.
* Generate tests so that for elements declared with
minOccurs="0" and maxOccurs="1" and empty value, then
export does not generate output.
Version 1.10a (05/11/2007)
* Added support for user methods. See section "User Methods" in
the documentation.
Version 1.9a (03/21/2007, again)
* Added process_includes.py which can be used as a pre-processor
to process include elements and create an XML Schema document
containing all included content.
* Modified generateDS.py so that it will read its input from a
pipe when given the command line argument "-" (dash).
Version 1.9a (02/13/2007, again)
* Changed naming of getter and setter methods. Default is to
use get_var() and set_var() instead of getVar() and setVar().
The old behavior is available using the flag
--use-old-getter-setter.
Version 1.9a (01/30/2007, again)
* Fix so that validator methods for simpleType are also
generated when the <xs:simpleType> occurs within an
<xs:element>.
Version 1.9a (12/04/2006, again)
* Fixed errors (occuring on import of superclass module) when
an element is defined as an extension of an element that is
defined as a simpleType restriction on an xs:string.
Version 1.9a (11/27/2006, again)
* Fix for elements that have attributes and no nested children.
Eliminated writing out new line chars in export methods.
Version 1.9a (10/22/2006, again)
* Fix to capture text content of nodes defined with attributes
but with no nested elements into member varialbe valueOf_.
Version 1.9a (10/10/2006)
* Added minimal support for simpleType.
* Generate stubs for and calls to validator methods for
simpleType.
* Retrieve bodies for validator methods for simpleTypes from
files in a directory specified with the --validator-bodies
command line flag.
Version 1.8d (10/4/2006, again)
* Fixed several errors related to anyAttribute. It was
generating bad code if an element was defined with
anyAttribute but had no other attributes. And, in the same
situation, it was not generating export code properly.
Version 1.8d (7/26/2006, again)
* Allowed dot/period as special character in element tags/names.
* Fixed several errors in generation of export and exportLiteral
functions. Special names (e.g. 'type', 'class') were not
being mapped to special spellings (e.g. 'ttype', 'klass', ).
* Fixed error in determining ExplicitDefine, which was
preventing export of some objects.
Version 1.8d (7/19/2006, again)
* Added support for empty elements, i.e. elements that have no
children and no attributes. Formerly, they were ignored due
to a quirk in logic.
Version 1.8d (4/13/2006)
* Added support for the following simple types: duration, anyURI
and unsignedShort. They are coerced to (and treated the same
as) xs:string, xs:string, and xs:integer, respectively
Version 1.8c (12/22/2005, again)
* Fixed use of mapped names in generateExportLiteralFn().
Version 1.8c (12/20/2005, again)
* Fix to generation of getters and setters for attributes.
Formerly generating accessors that handled *lists* of attribute
values.
Version 1.8c (12/15/2005, again)
* Fix generated code so that it uses documentElement instead of
childNodes[0] to get the root element.
Version 1.8c (5/10/2005, again)
* Patch for <xs:attribute ref="xxxx"/> -- Use the value of ref
as the name of the attribute. I'm not sure whether this is