-
Notifications
You must be signed in to change notification settings - Fork 1
/
generateDS.html
2605 lines (2561 loc) · 130 KB
/
generateDS.html
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
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.8: http://docutils.sourceforge.net/" />
<title>generateDS -- Generate Data Structures from XML Schema</title>
<meta name="author" content="Dave Kuhlman" />
<style type="text/css">
/* css */
body {
font: 90% 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
background: #ffffff;
color: black;
margin: 2em;
padding: 2em;
}
a[href] {
color: #436976;
background-color: transparent;
}
a.toc-backref {
text-decoration: none;
}
h1 a[href] {
text-decoration: none;
color: #fcb100;
background-color: transparent;
}
a.strong {
font-weight: bold;
}
img {
margin: 0;
border: 0;
}
p {
margin: 0.5em 0 1em 0;
line-height: 1.5em;
}
p a {
text-decoration: underline;
}
p a:visited {
color: purple;
background-color: transparent;
}
p a:active {
color: red;
background-color: transparent;
}
a:hover {
text-decoration: none;
}
p img {
border: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6 {
color: #003a6b;
background-color: transparent;
font: 100% 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
margin: 0;
padding-top: 0.5em;
}
h1 {
font-size: 160%;
margin-bottom: 0.5em;
border-bottom: 1px solid #fcb100;
}
h2 {
font-size: 140%;
margin-bottom: 0.5em;
border-bottom: 1px solid #aaa;
}
h3 {
font-size: 130%;
margin-bottom: 0.5em;
text-decoration: underline;
}
h4 {
font-size: 110%;
font-weight: bold;
}
h5 {
font-size: 100%;
font-weight: bold;
}
h6 {
font-size: 80%;
font-weight: bold;
}
ul a, ol a {
text-decoration: underline;
}
dt {
font-weight: bold;
}
dt a {
text-decoration: none;
}
dd {
line-height: 1.5em;
margin-bottom: 1em;
}
legend {
background: #ffffff;
padding: 0.5em;
}
form {
margin: 0;
}
dl.form {
margin: 0;
padding: 1em;
}
dl.form dt {
width: 30%;
float: left;
margin: 0;
padding: 0 0.5em 0.5em 0;
text-align: right;
}
input {
font: 100% 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
color: black;
background-color: white;
vertical-align: middle;
}
abbr, acronym, .explain {
color: black;
background-color: transparent;
}
q, blockquote {
}
code, pre {
font-family: monospace;
font-size: 1.2em;
display: block;
padding: 10px;
border: 1px solid #838183;
background-color: #eee;
color: #000;
overflow: auto;
margin: 0.5em 1em;
}
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
color: red ;
font-weight: bold ;
font-family: sans-serif }
tt.docutils {
background-color: #eeeeee;
}
</style>
</head>
<body>
<div class="document" id="generateds-generate-data-structures-from-xml-schema">
<h1 class="title">generateDS -- Generate Data Structures from XML Schema</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>Dave Kuhlman</td></tr>
<tr><th class="docinfo-name">Address:</th>
<td><pre class="address">
<a class="first reference external" href="mailto:dkuhlman@rexx.com">dkuhlman@rexx.com</a>
<a class="last reference external" href="http://www.rexx.com/~dkuhlman">http://www.rexx.com/~dkuhlman</a>
</pre>
</td></tr>
</tbody>
</table>
<!-- Do not modify the following version comments.
They are used by updateversion.py. -->
<!-- version -->
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.5a</td>
</tr>
</tbody>
</table>
<!-- version -->
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">date:</th><td class="field-body">June 06, 2011</td>
</tr>
</tbody>
</table>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">copyright:</th><td class="field-body">Copyright (c) 2004 Dave Kuhlman. This documentation
and the software it describes is covered by The MIT License:
<a class="reference external" href="http://www.opensource.org/licenses/mit-license.php">http://www.opensource.org/licenses/mit-license.php</a>.</td>
</tr>
<tr class="field"><th class="field-name">abstract:</th><td class="field-body"><tt class="docutils literal">generateDS.py</tt> generates Python data structures (for
example, class definitions) from an XML Schema document. These
data structures represent the elements in an XML document
described by the XML Schema. It also generates parsers that
load an XML document into those data structures. In addition,
a separate file containing subclasses (stubs) is optionally
generated. The user can add methods to the subclasses in order
to process the contents of an XML document.</td>
</tr>
</tbody>
</table>
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="auto-toc simple">
<li><a class="reference internal" href="#introduction" id="id7">1 Introduction</a></li>
<li><a class="reference internal" href="#where-to-find-it" id="id8">2 Where To find it</a><ul class="auto-toc">
<li><a class="reference internal" href="#download" id="id9">2.1 Download</a></li>
<li><a class="reference internal" href="#support-and-more-information" id="id10">2.2 Support and more information</a></li>
</ul>
</li>
<li><a class="reference internal" href="#how-to-build-and-install-it" id="id11">3 How to build and install it</a></li>
<li><a class="reference internal" href="#packaging-your-code" id="id12">4 Packaging your code</a></li>
<li><a class="reference internal" href="#the-command-line-interface-how-to-use-it" id="id13">5 The command line interface -- How to use it</a><ul class="auto-toc">
<li><a class="reference internal" href="#running-generateds-py" id="id14">5.1 Running <tt class="docutils literal">generateDS.py</tt></a></li>
<li><a class="reference internal" href="#name-conflicts" id="id15">5.2 Name conflicts</a><ul class="auto-toc">
<li><a class="reference internal" href="#conflicts-with-python-keywords" id="id16">5.2.1 Conflicts with Python keywords</a></li>
<li><a class="reference internal" href="#conflicts-between-child-elements-and-attributes" id="id17">5.2.2 Conflicts between child elements and attributes</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#the-graphical-user-interface-how-to-use-it" id="id18">6 The graphical user interface -- How to use it</a></li>
<li><a class="reference internal" href="#common-problems" id="id19">7 Common problems</a><ul class="auto-toc">
<li><a class="reference internal" href="#namespace-prefix-mis-match" id="id20">7.1 Namespace prefix mis-match</a></li>
</ul>
</li>
<li><a class="reference internal" href="#supported-features-of-xml-schema" id="id21">8 Supported features of XML Schema</a><ul class="auto-toc">
<li><a class="reference internal" href="#attributes-no-nested-children" id="id22">8.1 Attributes + no nested children</a></li>
<li><a class="reference internal" href="#mixed-content" id="id23">8.2 Mixed content</a></li>
<li><a class="reference internal" href="#anyattribute" id="id24">8.3 anyAttribute</a></li>
<li><a class="reference internal" href="#element-extensions" id="id25">8.4 Element extensions</a></li>
<li><a class="reference internal" href="#attribute-groups" id="id26">8.5 Attribute groups</a></li>
<li><a class="reference internal" href="#substitution-groups" id="id27">8.6 Substitution groups</a></li>
<li><a class="reference internal" href="#primitive-types" id="id28">8.7 Primitive types</a></li>
<li><a class="reference internal" href="#simpletype" id="id29">8.8 simpleType</a></li>
<li><a class="reference internal" href="#list-values-optional-values-maxoccurs-etc" id="id30">8.9 List values, optional values, maxOccurs, etc.</a></li>
<li><a class="reference internal" href="#simpletype-and-validators" id="id31">8.10 simpleType and validators</a></li>
<li><a class="reference internal" href="#include-file-processing" id="id32">8.11 Include file processing</a></li>
<li><a class="reference internal" href="#abstract-types" id="id33">8.12 Abstract types</a></li>
</ul>
</li>
<li><a class="reference internal" href="#the-xml-schema-input-to-generateds" id="id34">9 The XML schema input to generateDS</a><ul class="auto-toc">
<li><a class="reference internal" href="#additional-constructions" id="id35">9.1 Additional constructions</a><ul class="auto-toc">
<li><a class="reference internal" href="#complextype-at-top-level" id="id36">9.1.1 <complexType> at top-level</a></li>
<li><a class="reference internal" href="#use-of-ref-instead-of-name-and-type-attributes" id="id37">9.1.2 Use of "ref" instead of "name" and "type" attributes</a></li>
<li><a class="reference internal" href="#extension-types" id="id38">9.1.3 Extension types</a></li>
<li><a class="reference internal" href="#elements-containing-mixed-content" id="id39">9.1.4 Elements containing mixed content</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#id2" id="id40">10 XMLBehaviors</a><ul class="auto-toc">
<li><a class="reference internal" href="#the-xmlbehaviors-input-file" id="id41">10.1 The XMLBehaviors input file</a></li>
<li><a class="reference internal" href="#implementing-other-sources-for-implementation-bodies" id="id42">10.2 Implementing other sources for implementation bodies</a></li>
</ul>
</li>
<li><a class="reference internal" href="#additional-features" id="id43">11 Additional features</a><ul class="auto-toc">
<li><a class="reference internal" href="#xsd-list-element-support" id="id44">11.1 xsd:list element support</a></li>
<li><a class="reference internal" href="#xsd-enumeration-support" id="id45">11.2 xsd:enumeration support</a></li>
<li><a class="reference internal" href="#xsd-union-support" id="id46">11.3 xsd:union support</a></li>
<li><a class="reference internal" href="#extended-xsd-choice-support" id="id47">11.4 Extended xsd:choice support</a></li>
<li><a class="reference internal" href="#minoccurs-attribute-support" id="id48">11.5 minOccurs attribute support</a></li>
<li><a class="reference internal" href="#more-thorough-content-type-and-base-type-resolution" id="id49">11.6 More thorough content type and base type resolution</a></li>
<li><a class="reference internal" href="#making-top-level-simpletypes-available-from-xschemahandler" id="id50">11.7 Making top level simpleTypes available from XschemaHandler</a></li>
<li><a class="reference internal" href="#namespaces-inserting-namespace-definition-in-exported-documents" id="id51">11.8 Namespaces -- inserting namespace definition in exported documents</a></li>
</ul>
</li>
<li><a class="reference internal" href="#how-to-use-the-generated-source-code" id="id52">12 How-to Use the generated source code</a><ul class="auto-toc">
<li><a class="reference internal" href="#the-parsing-functions" id="id53">12.1 The parsing functions</a></li>
<li><a class="reference internal" href="#recognizing-the-top-level-element" id="id54">12.2 Recognizing the top level element</a></li>
<li><a class="reference internal" href="#the-export-methods" id="id55">12.3 The export methods</a><ul class="auto-toc">
<li><a class="reference internal" href="#method-export" id="id56">12.3.1 Method export</a></li>
<li><a class="reference internal" href="#method-exportliteral" id="id57">12.3.2 Method <tt class="docutils literal">exportLiteral</tt></a><ul class="auto-toc">
<li><a class="reference internal" href="#what-it-does" id="id58">12.3.2.1 What It Does</a></li>
<li><a class="reference internal" href="#why-you-might-care" id="id59">12.3.2.2 Why You Might Care</a></li>
<li><a class="reference internal" href="#how-to-use-it" id="id60">12.3.2.3 How to use it</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#building-instances" id="id61">12.4 Building instances</a></li>
<li><a class="reference internal" href="#using-the-subclass-module" id="id62">12.5 Using the subclass module</a></li>
<li><a class="reference internal" href="#elements-with-attributes-but-no-nested-children" id="id63">12.6 Elements with attributes but no nested children</a></li>
<li><a class="reference internal" href="#id4" id="id64">12.7 Mixed content</a></li>
<li><a class="reference internal" href="#id6" id="id65">12.8 anyAttribute</a></li>
<li><a class="reference internal" href="#user-methods" id="id66">12.9 User Methods</a></li>
<li><a class="reference internal" href="#overridable-methods" id="id67">12.10 Overridable methods</a></li>
</ul>
</li>
<li><a class="reference internal" href="#how-to-modify-the-generated-code" id="id68">13 How to modify the generated code</a><ul class="auto-toc">
<li><a class="reference internal" href="#adding-features-to-class-definitions" id="id69">13.1 Adding features to class definitions</a></li>
</ul>
</li>
<li><a class="reference internal" href="#examples-and-demonstrations" id="id70">14 Examples and demonstrations</a><ul class="auto-toc">
<li><a class="reference internal" href="#django-generating-models-and-forms" id="id71">14.1 Django -- Generating Models and Forms</a><ul class="auto-toc">
<li><a class="reference internal" href="#how-to-generate-django-models-and-forms" id="id72">14.1.1 How to generate Django models and forms</a></li>
<li><a class="reference internal" href="#how-it-works" id="id73">14.1.2 How it works</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#sample-code-and-extensions" id="id74">15 Sample code and extensions</a><ul class="auto-toc">
<li><a class="reference internal" href="#capturing-xs-date-elements-as-dates" id="id75">15.1 Capturing xs:date elements as dates</a></li>
</ul>
</li>
<li><a class="reference internal" href="#limitations-of-generateds" id="id76">16 Limitations of generateDS</a><ul class="auto-toc">
<li><a class="reference internal" href="#xml-schema-limitations" id="id77">16.1 XML Schema limitations</a></li>
<li><a class="reference internal" href="#large-documents" id="id78">16.2 Large documents</a></li>
</ul>
</li>
<li><a class="reference internal" href="#includes-the-xml-schema-include-element" id="id79">17 Includes -- The XML schema include element</a></li>
<li><a class="reference internal" href="#acknowledgments" id="id80">18 Acknowledgments</a></li>
<li><a class="reference internal" href="#see-also" id="id81">19 See also</a></li>
</ul>
</div>
<div class="section" id="introduction">
<h1><a class="toc-backref" href="#id7">1 Introduction</a></h1>
<p><tt class="docutils literal">generateDS.py</tt> generates Python data structures (for example,
class definitions) from an XML Schema document. These data
structures represent the elements in an XML document described by
the XML Schema. It also generates parsers that load an XML
document into those data structures. In addition, a separate file
containing subclasses (stubs) is optionally generated. The user
can add methods to the subclasses in order to process the contents
of an XML document.</p>
<p>The generated Python code contains:</p>
<ul class="simple">
<li>A class definition for each element defined in the XML Schema
document.</li>
<li>A main and driver function that can be used to test the
generated code.</li>
<li>A parser that will read an XML document which satisfies the XML
Schema from which the parser was generated. The parser creates
and populates a tree structure of instances of the generated
Python classes.</li>
<li>Methods in each class to export the instance back out to XML
(method <tt class="docutils literal">export</tt>) and to export the instance to a literal
representing the Python data structure (method
<tt class="docutils literal">exportLiteral</tt>).</li>
</ul>
<p>The generated classes contain the following:</p>
<ul class="simple">
<li>A constructor method (__init__), with member variable
initializers.</li>
<li>Methods with names 'getX' and 'setX' for each member variable
'X' or, if the member variable is defined with
maxOccurs="unbounded", methods with names 'getX', 'setX',
'addX', and 'insertX'.</li>
<li>A "build" method that can be used to populate an instance of the
class from a node in a minidom tree.</li>
<li>An "export" method that will write the instance (and any nested
sub-instances) to a file object as XML text.</li>
<li>An "exportLiteral" method that will write the instance (and any
nested sub-instances) to a file object as Python literals (text).</li>
</ul>
<p>The generated subclass file contains one (sub-)class definition
for each data representation class. If the subclass file is used,
then the parser creates instances of the subclasses (instead of
creating instances of the superclasses). This enables the user to
extend the subclasses with "tree walk" methods, for example, that
process the contents of the XML file. The user can also generate
and extend multiple subclass files which use a single, common
superclass file, thus implementing a number of different processes
on the same XML document type.</p>
<p>This document explains (1) how to use <tt class="docutils literal">generateDS.py</tt>; (2) how
to use the Python code and data structures that it generates; and
(3) how to modify the generated code for special purposes.</p>
<p>There is also support for packaging the code you generate with
<tt class="docutils literal">generateDS.py</tt>. See <a class="reference internal" href="#packaging-your-code">Packaging your code</a>.</p>
</div>
<div class="section" id="where-to-find-it">
<h1><a class="toc-backref" href="#id8">2 Where To find it</a></h1>
<div class="section" id="download">
<h2><a class="toc-backref" href="#id9">2.1 Download</a></h2>
<!-- Do not modify the following version comments.
They are used by updateversion.py. -->
<p>You can find the source distribution here:</p>
<ul class="simple">
<li><a class="reference external" href="http://pypi.python.org/pypi/generateDS/">Python Package Index --
http://pypi.python.org/pypi/generateDS/</a></li>
<li><a class="reference external" href="http://sourceforge.net/projects/generateds/">Source Forge --
http://sourceforge.net/projects/generateds/</a></li>
</ul>
<!-- version -->
<ul class="simple">
<li>My Web site -- <a class="reference external" href="http://www.rexx.com/~dkuhlman/generateDS-2.5a.tar.gz">http://www.rexx.com/~dkuhlman/generateDS-2.5a.tar.gz</a></li>
</ul>
<!-- version -->
</div>
<div class="section" id="support-and-more-information">
<h2><a class="toc-backref" href="#id10">2.2 Support and more information</a></h2>
<p>There is a mailing list at SourceForge:
<a class="reference external" href="https://lists.sourceforge.net/lists/listinfo/generateds-users">generateds-users --
https://lists.sourceforge.net/lists/listinfo/generateds-users</a>.</p>
<p>There is a tutorial in the distribution:
<tt class="docutils literal">tutorial/tutorial.html</tt> and at
<a class="reference external" href="http://www.rexx.com/~dkuhlman/generateds_tutorial.html">generateDS -- Introduction and Tutorial --
http://www.rexx.com/~dkuhlman/generateds_tutorial.html</a>.</p>
</div>
</div>
<div class="section" id="how-to-build-and-install-it">
<h1><a class="toc-backref" href="#id11">3 How to build and install it</a></h1>
<p>Newer versions of Python have XML support in the Python standard
library. For older versions of Python, install PyXML. You can find
it at: <a class="reference external" href="http://pyxml.sourceforge.net/">http://pyxml.sourceforge.net/</a></p>
<p>De-compress the <tt class="docutils literal">generateDS</tt> distribution file. Use something
like the following:</p>
<pre class="literal-block">
tar xzvf generateDS-x.xx.tar.gz
</pre>
<p>Then, the regular Distutils commands should work:</p>
<pre class="literal-block">
$ cd generateDS-x.xx
$ python setup.py build
$ python setup.py install # probably as root
</pre>
</div>
<div class="section" id="packaging-your-code">
<h1><a class="toc-backref" href="#id12">4 Packaging your code</a></h1>
<p>There is some support for packaging the code you generate with
<tt class="docutils literal">generateDS.py</tt>. This support helps you to produce a directory
structure with places to put sample code, sample XML instance
documents, and utility code for use with your generated module. It
also assists you in using <a class="reference external" href="http://sphinx.pocoo.org/">Sphinx</a> to
generate documentation for your module.</p>
<p>Instructions on how to use it are here:
<a class="reference external" href="schema_package_howto.html">How to package a generateDS.py generated library --
schema_package_howto.html</a></p>
<p>And the package building support itself is here:
<a class="reference external" href="http://www.rexx.com/~dkuhlman/librarytemplate0-1.0a.zip">http://www.rexx.com/~dkuhlman/librarytemplate0-1.0a.zip</a></p>
</div>
<div class="section" id="the-command-line-interface-how-to-use-it">
<h1><a class="toc-backref" href="#id13">5 The command line interface -- How to use it</a></h1>
<div class="section" id="running-generateds-py">
<h2><a class="toc-backref" href="#id14">5.1 Running <tt class="docutils literal">generateDS.py</tt></a></h2>
<p>Run <tt class="docutils literal">generateDS.py</tt> with a single argument, the XML Schema file
that defines the data structures. For example, the following will
generate Python source code for data structures described in
people.xsd and will write it to the file people.py. In addition,
it will write subclass stubs to the file peoplesubs.py:</p>
<pre class="literal-block">
python generateDS.py -o people.py -s peoplesubs.py people.xsd
</pre>
<p>Here is the usage message displayed by <tt class="docutils literal">generateDS.py</tt>:</p>
<pre class="literal-block">
Synopsis:
Generate Python classes from XML Schema definition.
Input is read from in_xsd_file or, if "-" (dash) arg, from stdin.
Output is written to files named in "-o" and "-s" options.
Usage:
python generateDS.py [ options ] <xsd_file>
python generateDS.py [ options ] -
Options:
-h, --help Display this help information.
-o <outfilename> Output file name for data representation classes
-s <subclassfilename> Output file name for subclasses
-p <prefix> Prefix string to be pre-pended to the class names
-f Force creation of output files. Do not ask.
-a <namespaceabbrev> Namespace abbreviation, e.g. "xsd:".
Default = 'xs:'.
-b <behaviorfilename> Input file name for behaviors added to subclasses
-m Generate properties for member variables
--subclass-suffix="XXX" Append XXX to the generated subclass names.
Default="Sub".
--root-element="XXX" Assume XXX is root element of instance docs.
Default is first element defined in schema.
--super="XXX" Super module name in subclass module. Default="???"
--validator-bodies=path Path to a directory containing files that provide
bodies (implementations) of validator methods.
--use-old-getter-setter Name getters and setters getVar() and setVar(),
instead of get_var() and set_var().
--user-methods= <module>,
-u <module> Optional module containing user methods. See
section "User Methods" in the documentation.
--no-dates Do not include the current date in the generated
files. This is useful if you want to minimize
the amount of (no-operation) changes to the
generated python code.
--no-versions Do not include the current version in the generated
files. This is useful if you want to minimize
the amount of (no-operation) changes to the
generated python code.
--no-process-includes Do not process included XML Schema files. By
default, generateDS.py will insert content
from files referenced by <include ... />
elements into the XML Schema to be processed.
--silence Normally, the code generated with generateDS
echoes the information being parsed. To prevent
the echo from occurring, use the --silence switch.
--namespacedef='xmlns:abc="http://www.abc.com"'
Namespace definition to be passed in as the
value for the namespacedef_ parameter of
the export() method by the generated
parse() and parseString() functions.
Default=''.
--external-encoding=<encoding>
Encode output written by the generated export
methods using this encoding. Default, if omitted,
is the value returned by sys.getdefaultencoding().
Example: --external-encoding='utf-8'.
--member-specs=list|dict
Generate member (type) specifications in each
class: a dictionary of instances of class
MemberSpec_ containing member name, type,
and array or not. Allowed values are
"list" or "dict". Default: None.
--session=mysession.session
Load and use options from session file. You can
create session file in generateds_gui.py.
--version Print version and exit.
</pre>
<p>The following command line flags are recognized by <tt class="docutils literal">generateDS.py</tt>:</p>
<dl class="docutils">
<dt>o <filename></dt>
<dd>Write the data representation classes to file filename.</dd>
<dt>s <filename></dt>
<dd>Write the subclass stubs to file filename.</dd>
<dt>p <prefix></dt>
<dd>Prepend prefix to the name of each generated data structure
(class).</dd>
<dt>f</dt>
<dd>Force generation of output files even if they already exist.
Do not ask before over-writing existing files.</dd>
<dt>a <namespaceabbrev></dt>
<dd><p class="first">Namespace abbreviation, for example "xsd:". The default is
'xs:'. If the <tt class="docutils literal"><schema> element</tt> in your XML Schema,
specifies something other than "xmlns:xs=", then you need to
use this option. So, suppose you have the following at the
beginning of your XSchema file:</p>
<pre class="literal-block">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</pre>
<p>Then you can the following command line option:</p>
<pre class="literal-block">
-a "xsd:"
</pre>
<p class="last">But, note that <tt class="docutils literal">generateDS.py</tt> also tries to pick-up the
namespace prefix used in the XMLSchema file automatically. If
the <schema> element has an attribute "xmlns:xxx" whose value
is "http://www.w3.org/2001/XMLSchema", then <tt class="docutils literal">generateDS.py</tt>
will use "xxx:" as the alias for the XMLSchema namespace in
the XMLSchema document.</p>
</dd>
<dt>b <behaviorfilename></dt>
<dd>Input file name for behaviors to be added to subclasses.
Specifies is the name of an XML document containing
descriptions of methods to be added to subclasses generated
with the -s flag. The -b flag requires the -s flag. See the
section on <a class="reference internal" href="#xmlbehaviors">XMLBehaviors</a> below.</dd>
<dt>m</dt>
<dd>Generate property members and new style classes. Causes
generated classes to inherit from class object. Generates
a call to the built-in property function for each pair of
getters and setters. This is experimental.</dd>
<dt>subclass-suffix=<suffix></dt>
<dd><p class="first">Append suffix to the name of classes generated in the subclass
file. The default, if omitted, is "Sub". For example, the
following will append "_Action" to each generated subclass
name:</p>
<pre class="literal-block">
generateDS.py --subclass-suffix="_Action" -s actions.py mydef.xsd
</pre>
<p>And the following will append nothing, making the superclass
and subclass names the same:</p>
<pre class="last literal-block">
generateDS.py --subclass-suffix="" -s actions.py mydef.xsd
</pre>
</dd>
<dt>root-element=<element_name></dt>
<dd>Make element_name the assumed root of instance documents. The
default is the name of the element whose definition is first
in the XML Schema document. This flag effects the parsing
functions (for example, parse(), parseString()).</dd>
<dt>super=<module_name></dt>
<dd><p class="first">Make module_name the name of the superclass module imported
by the subclass module. If this flag is omitted, the
following is generated near the top of the subclass file:</p>
<pre class="literal-block">
import ??? as supermod
</pre>
<p class="last">and you will need to hand edit this so the correct superclass
module is imported.</p>
</dd>
<dt>validator-bodies=<path></dt>
<dd>Obtain the bodies (implementations) for validator methods for
members defined as <tt class="docutils literal">simpleType</tt> from files in directory
specified by <tt class="docutils literal"><path></tt>. The name of the file in that
directory should be the same as the <tt class="docutils literal">simpleType</tt> name with
an optional ".py" extension. If a file is not provided for a
given type, an empty body (<tt class="docutils literal">pass</tt>) is generated. In these
files, lines with "##" in the first two columns are ignored
and are not inserted.</dd>
<dt>use-old-getter-setter</dt>
<dd><tt class="docutils literal">generateDS.py</tt> now generates getter and setter methods (for
variable "abc", for example) with the names get_abc() and
set_abc(), which I believe is a more Pythonic style, instead
of getAbc() and setAbc(), which was the old behavior. Use
this flag to generate getters and setters in the old style
(getAbc() and setAbc()).</dd>
<dt>u, user-methods=<module></dt>
<dd>If specified, <tt class="docutils literal">generateDS.py</tt> will add methods to generated
classes as specified in the indicated module. For more
information, see section <a class="reference internal" href="#user-methods">User Methods</a>.</dd>
<dt>no-dates</dt>
<dd>Do not include the current date in the generated files. This is
useful if you want to minimize the amount of (no-operation)
changes to the generated python code.</dd>
<dt>no-versions</dt>
<dd>Do not include the current version in the generated files. This is
useful if you want to minimize the amount of (no-operation)
changes to the generated python code.</dd>
<dt>no-process-includes</dt>
<dd>Do not process included XML Schema files. By default,
generateDS.py will insert content from files referenced by
<tt class="docutils literal"><include ... /></tt> elements into the XML Schema to be processed.
See section <a class="reference internal" href="#include-file-processing">Include file processing</a>.</dd>
<dt>silence</dt>
<dd>Normally, the code generated with generateDS echoes the
information being parsed. To prevent the echo from occurring,
use the --silence switch. This switch causes generateDS.py,
when it generates boiler-plate parsing functions, (parse(),
parseString(), parseLiteral()), to generate code that does
<em>not</em> print out output (export output to stdout).</dd>
<dt>namespacedef="<<a class="reference external" href="http://...">http://...</a>>"</dt>
<dd>Namespace definition to be passed in as the value for the
<tt class="docutils literal">namespacedef_</tt> parameter of the export() method by the generated
parse() and parseString() functions. If this parameter is
specified, then the export function will insert a namespace
prefix definition attribute in the top-most (outer-most)
element. (Actually, you can insert any attribute.) The default
is an empty string.</dd>
<dt>external-encoding=<encoding></dt>
<dd>If an XML instance document contains character data or
attribute values that are not in the ASCII character set, then
that data will not be written out correctly or will throw an
exception. This flag enables the user to specify a character
encoding into which character data will be encoded before it is
written out by the export functions. The generated export
methods encode data using this encoding. The default value, if
this flag is omitted, is the value returned by
sys.getdefaultencoding(). You can find a list of standard
encodings here: <a class="reference external" href="http://docs.python.org/library/codecs.html#id3">http://docs.python.org/library/codecs.html#id3</a>.
Example use: --external-encoding='utf-8'.</dd>
<dt>member-specs</dt>
<dd>Generate member (type) specifications in each class: a
dictionary of instances of class <tt class="docutils literal">MemberSpec_</tt> containing
member name, type, and array or not. See <a class="reference internal" href="#user-methods">User Methods</a>
section for more information about <tt class="docutils literal">MemberSpec_</tt>. Allowed
values are "list" or "dict". Default: do <em>not</em> generate member
specifications (unless --user-methods specified).</dd>
<dt>session=mysession.session</dt>
<dd>Load and use options from session file. You can create a
session file in generateds_gui.py, the graphical front-end for
generateDS.py. Additional options on the command line can be
used to override options in the session file. A session file
is an XML document, so you can modify it with a text editor.</dd>
<dt>version</dt>
<dd>Print out the current version of generateDS.py and immediately
exit.</dd>
</dl>
</div>
<div class="section" id="name-conflicts">
<h2><a class="toc-backref" href="#id15">5.2 Name conflicts</a></h2>
<div class="section" id="conflicts-with-python-keywords">
<h3><a class="toc-backref" href="#id16">5.2.1 Conflicts with Python keywords</a></h3>
<p>In some cases the element and attribute names in an XML document
will conflict with Python keywords. There are two solutions to fixing
and avoiding name conflicts:</p>
<ul>
<li><p class="first">In an attempt to avoid these clashes, <tt class="docutils literal">generateDS.py</tt> contains a
table that maps names that might clash to acceptable names. This
table is a Python dictionary named <tt class="docutils literal">NameTable</tt>. The user can
modify existing entries in this table within <tt class="docutils literal">generateDS.py</tt>
itself and add additional name-replacement pairs to this table, for
example, if new conflicts occur.</p>
</li>
<li><p class="first">Or, you can fix additional conflicts by following these steps:</p>
<ol class="arabic">
<li><p class="first">Create a module named <tt class="docutils literal">generateds_config.py</tt>.</p>
</li>
<li><p class="first">Define a dictionary in that module named <tt class="docutils literal">NameTable</tt>.</p>
</li>
<li><p class="first">Place additional name mappings in that dictionary. Here is a
sample:</p>
<pre class="literal-block">
NameTable = {
'range': 'rangeType',
}
</pre>
</li>
</ol>
<ol class="arabic simple" start="3">
<li>And, place that module where <tt class="docutils literal">generateDS.py</tt> can import it, or
place the directory containing that module on your
<tt class="docutils literal">PYTHONPATH</tt> environment variable.</li>
</ol>
<p><tt class="docutils literal">generateDS.py</tt> will attempt to import that module
(<tt class="docutils literal">generateds_config.py</tt>) and will add the name mappings in it to
the default set of mappings in <tt class="docutils literal">NameTable</tt> in <tt class="docutils literal">generateDS.py</tt>
itself.</p>
</li>
</ul>
</div>
<div class="section" id="conflicts-between-child-elements-and-attributes">
<h3><a class="toc-backref" href="#id17">5.2.2 Conflicts between child elements and attributes</a></h3>
<p>In some cases the name of a child element and the name of an
attribute will be the same. (I believe, but am not sure, that
this is allowed by XML Schema.) Since generateDS.py treats both
child elements and attributes as members of the generated class,
this is a name conflict. Therefore, where such conflicts exist,
generateDS.py modifies the name of the attribute by adding "_attr"
to its name.</p>
</div>
</div>
</div>
<div class="section" id="the-graphical-user-interface-how-to-use-it">
<h1><a class="toc-backref" href="#id18">6 The graphical user interface -- How to use it</a></h1>
<p>Here are a few notes on how to use the GUI front-end.</p>
<ul>
<li><p class="first"><tt class="docutils literal">generateds_gui.py</tt> is installed when you do the standard
installation:</p>
<pre class="literal-block">
$ python setup.py install
</pre>
</li>
<li><p class="first">Run it by typing the following at the command line:</p>
<pre class="literal-block">
$ generateds_gui.py
</pre>
</li>
<li><p class="first">For help with command line options, run:</p>
<pre class="literal-block">
$ generateds_gui.py --help
</pre>
</li>
<li><p class="first">For a description of the values and flags that you can set, see
section <a class="reference internal" href="#running-generateds-py">Running generateDS.py</a>. There are also tool tips on
the various widgets in the graphical user interface.</p>
</li>
<li><p class="first">Generate the python bindings modules by using the
<tt class="docutils literal">Tools/Generate</tt> menu item or the <tt class="docutils literal">Generate</tt> button at the
bottom of the window.</p>
</li>
<li><p class="first">Capture the command line generated by using the
<tt class="docutils literal">Tools/Capture command line</tt> menu item. You might consider copying and
pasting that command line into a shell script or batch file for
repeated reuse.</p>
</li>
<li><p class="first">You can also save and later reload your values and
flags in a session file. See the <tt class="docutils literal">Save session</tt>,
<tt class="docutils literal">Save session as</tt>, and <tt class="docutils literal">Load session</tt> items under the <tt class="docutils literal">File</tt> menu.
By default, a session file has the extension ".session".</p>
</li>
<li><p class="first">You can load a session on start-up with the "-s" or "--session"
comand line options. For example:</p>
<pre class="literal-block">
$ generateds_gui.py --session=mybindingsjob.session
</pre>
<p>Or, use the "session" option in a configuration file.</p>
</li>
<li><p class="first">If the command to be run when generating bindings is not
standard, you can specify that command with the "--exec-path"
command line option or with the "exec-path" option configuration
file. The default is "generateDS.py".</p>
</li>
<li><p class="first">Command line options can also be specified in a configuration
file. <tt class="docutils literal">generateds_gui.py</tt> checks for that configuration file in
the following locations in this order:</p>
<ol class="arabic simple">
<li><tt class="docutils literal"><span class="pre">~/.generateds_gui.ini</span></tt></li>
<li><tt class="docutils literal">./generateds_gui.ini</tt></li>
</ol>
<p>Here is a sample configuration file:</p>
<pre class="literal-block">
[general]
exec-path: /usr/bin/python ~/bin/generateDS.py
impl-path: generateds_gui.glade
session: a1.session
</pre>
<p>Options on the command line override options in configuration
files.</p>
</li>
</ul>
</div>
<div class="section" id="common-problems">
<h1><a class="toc-backref" href="#id19">7 Common problems</a></h1>
<div class="section" id="namespace-prefix-mis-match">
<h2><a class="toc-backref" href="#id20">7.1 Namespace prefix mis-match</a></h2>
<p><tt class="docutils literal">generateDS.py</tt> is not very intelligent about detecting what
prefix is used in the schema file for the XML Schema namespace.
When this problem occurs, you may see the following when running
<tt class="docutils literal">generateDS.py</tt>:</p>
<pre class="literal-block">
AttributeError: 'NoneType' object has no attribute 'annotate'
</pre>
<p><tt class="docutils literal">generateDS.py</tt> assumes that the XML Schema namespace prefix in
your schema is "xs:".</p>
<p>So, if the XML Schema namespace prefix in your schema is not "xs:",
you will need to use the "-a" command line option when you run
<tt class="docutils literal">generateDS.py</tt>. Here is an example:</p>
<pre class="literal-block">
generateDS.py -a "xsd:" --super=mylib -o mylib.py -s myapp.py someschema.xsd
</pre>
</div>
</div>
<div class="section" id="supported-features-of-xml-schema">
<h1><a class="toc-backref" href="#id21">8 Supported features of XML Schema</a></h1>
<p>The following constructs, among others, in XML Schema are
supported:</p>
<ul class="simple">
<li>Attributes of types xs:string, xs:integer, xs:float, and
xs:boolean.</li>
<li>Repeated sub-elements specified with maxOccurs="unbounded".</li>
<li>Sub-elements of simple types xs:string, xs:integer, and xs:float.</li>
<li>Sub-elements of complex types defined separately in the XML
Schema document.</li>
</ul>
<p>See file people.xsd for examples of the definition of data types
and structures. Also see the section on <a class="reference internal" href="#the-xml-schema-input-to-generateds">The XML Schema Input
to generateDS</a>.</p>
<div class="section" id="attributes-no-nested-children">
<h2><a class="toc-backref" href="#id22">8.1 Attributes + no nested children</a></h2>
<p>Element definitions that contain attributes but <em>no</em> nested child
elements provide access to their data content through getter and
setter methods <tt class="docutils literal">getValueOf_</tt> and <tt class="docutils literal">setValueOf_</tt> and member
variable <tt class="docutils literal">valueOf_</tt>.</p>
</div>
<div class="section" id="mixed-content">
<h2><a class="toc-backref" href="#id23">8.2 Mixed content</a></h2>
<p>Elements that are defined to contain both text and nested child
elements have "mixed content". <tt class="docutils literal">generateDS.py</tt> provides access
to mixed content, but the generated data structures (classes) are
fundamentally different from that generated for other elements.
See section <a class="reference internal" href="#id3">Mixed content</a> for more details.</p>
<p>Note that elements defined with attributes but with <em>no</em> nested
sub-elements do not need to be declared as "mixed". For these
elements, character data is captured in a member variable
<tt class="docutils literal">valueOf_</tt>, and can be accessed with member methods
<tt class="docutils literal">getValueOf_</tt> and <tt class="docutils literal">setValueOf_</tt>.</p>
</div>
<div class="section" id="anyattribute">
<h2><a class="toc-backref" href="#id24">8.3 anyAttribute</a></h2>
<p><tt class="docutils literal">generateDS.py</tt> supports <tt class="docutils literal">anyAttribute</tt>. For example, if an
element is defined as follows:</p>
<pre class="literal-block">
<xs:element name="Tool">
<xs:complexType>
<xs:attribute name="PartNumber" type="xs:string" />
<xs:anyAttribute processContents="skip" />
</xs:complexType>
</xs:element>
</pre>
<p>Then <tt class="docutils literal">generateDS.py</tt> will generate a class with a member
variable <tt class="docutils literal">anyAttributes_</tt> containing a dictionary. Any
attributes found in the instance XML document that are not
explicitly defined for this element will be stored in this
dictionary. <tt class="docutils literal">generateDS.py</tt> also generates getters and setters
as well as code for parsing and export. <tt class="docutils literal">generateDS.py</tt> ignores
<tt class="docutils literal">processContents</tt>. See section <a class="reference internal" href="#id5">anyAttribute</a> for more details.</p>
</div>
<div class="section" id="element-extensions">
<h2><a class="toc-backref" href="#id25">8.4 Element extensions</a></h2>
<p><tt class="docutils literal">generateDS.py</tt> now generates subclasses for extensions, that is
when an element definition contains something like this:</p>
<pre class="literal-block">
<xs:extension base="sometag">
</pre>
<p><strong>Limitation</strong> -- There is an important limitation, however:
member names duplicated (overridden ?) in an extension generate
erroneous code. Sigh. I guess I needed something more to do.</p>
<p>Several of the generated methods have been refactored so that
subclasses can reuse the code in their superclasses. Take a look
at the generated code to learn how to use it.</p>
<p>The Python compiler/interpreter requires that it has seen a
superclass before it sees the subclass that uses it. Because of
this, <tt class="docutils literal">generateDS.py</tt> delays generating a subclass until after
its superclass has been generated. Therefore, the order in which
classes are generated may be different from what you expect.</p>
</div>
<div class="section" id="attribute-groups">
<h2><a class="toc-backref" href="#id26">8.5 Attribute groups</a></h2>
<p><tt class="docutils literal">generateDS.py</tt> now handles definition and use of attribute
groups. For example: the use of something like the following:</p>
<pre class="literal-block">
<xs:attributeGroup name="favorites">
<xs:attribute name="fruit" />
<xs:attribute name="vegetable" />
</xs:attributeGroup>
</pre>
<p>And, a reference or use like the following:</p>
<pre class="literal-block">
<xs:element name="person">
<xs:complexType mixed="0">
<xs:attributeGroup ref="favorites" />
o
o
o
</pre>
<p>Results in generation of class <tt class="docutils literal">person</tt> that contains members
<tt class="docutils literal">fruit</tt> and <tt class="docutils literal">vegetable</tt>.</p>
</div>
<div class="section" id="substitution-groups">
<h2><a class="toc-backref" href="#id27">8.6 Substitution groups</a></h2>
<p><tt class="docutils literal">generateDS.py</tt> now handles a limited range of substitution
groups, but, there is an important <strong>limitation</strong>, in particular
<tt class="docutils literal">generateDS.py</tt> handles substitution groups that involve complex
types, but does not handle those that involve (substitute for)
simple types (for example, xs:string, xs:integer, etc). This is
because the code generated for members defined as simple types
does not provide the needed information to handle substitution
groups.</p>
</div>
<div class="section" id="primitive-types">
<h2><a class="toc-backref" href="#id28">8.7 Primitive types</a></h2>
<p><tt class="docutils literal">generateDS.py</tt> supports some, but not all, simple types defined
in "XML Schema Part 0: Primer Second Edition" (
<a class="reference external" href="http://www.w3.org/TR/xmlschema-0/">http://www.w3.org/TR/xmlschema-0/</a>. See section "Simple Types" and
appendix B). Validation is performed for some simple types. When
performed, validation is done while the XML document is being read
and instances are created.</p>
<p>Here is a list of supported simple types:</p>
<ul class="simple">
<li><tt class="docutils literal">xs:string</tt> -- No validation.</li>
<li><tt class="docutils literal">xs:token</tt> -- No validation. White space between tokens is
coerced to a single blank between tokens.</li>
<li><tt class="docutils literal">xs:integer</tt>, <tt class="docutils literal">xs:short</tt>, <tt class="docutils literal">xs:long</tt>. <tt class="docutils literal">xs:int</tt> -- All
treated the same. Checked for valid integer.</li>
<li><tt class="docutils literal">xs:float</tt>, <tt class="docutils literal">xs:double</tt>, <tt class="docutils literal">xs:decimal</tt> -- All treated the
same. Checked for valid float.</li>
<li><tt class="docutils literal">xs:positiveInteger</tt> -- Checked for valid range (> 0).</li>
<li><tt class="docutils literal">xs:nonPositiveInteger</tt> -- Checked for valid range (<= 0).</li>
<li><tt class="docutils literal">xs:negativeInteger</tt> -- Checked for valid range (< 0).</li>
<li><tt class="docutils literal">xs:nonNegativeInteger</tt> -- Checked for valid range (>= 0).</li>
<li><tt class="docutils literal">xs:date</tt>, <tt class="docutils literal">xs:dateTime</tt> -- All treated the same. No
validation.</li>
<li><tt class="docutils literal">xs:boolean</tt> -- Checked for one of <tt class="docutils literal">0</tt>, <tt class="docutils literal">false</tt>, <tt class="docutils literal">1</tt>,
<tt class="docutils literal">true</tt>.</li>
</ul>
</div>
<div class="section" id="simpletype">
<h2><a class="toc-backref" href="#id29">8.8 simpleType</a></h2>
<p><tt class="docutils literal">generateDS.py</tt> generates minimal support for members defined as
<tt class="docutils literal">simpleType</tt>. However, the code generated by <tt class="docutils literal">generateDS.py</tt>
does <strong>not</strong> enforce restrictions. For notes on how to enforce
restrictions, see section <a class="reference internal" href="#simpletype-and-validators">simpleType and validators</a>.</p>
<p>A <tt class="docutils literal">simpleType</tt> can be a restriction on a primitive type or on a
defined element type. So, for example, the following will
generate valid code:</p>
<pre class="literal-block">
<xs:element name="percent">
<xs:simpleType>