forked from duanlizhi/gooxml
/
common.go
1341 lines (1224 loc) · 25.9 KB
/
common.go
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
// Copyright 2017 Baliance. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
//
// Use of this source code is governed by the terms of the Affero GNU General
// Public License version 3.0 as published by the Free Software Foundation and
// appearing in the file LICENSE included in the packaging of this file. A
// commercial license can be purchased by contacting sales@baliance.com.
package sharedTypes
import (
"encoding/xml"
"fmt"
"regexp"
)
const ST_GuidPattern = `\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}`
var ST_GuidPatternRe = regexp.MustCompile(ST_GuidPattern)
const ST_UniversalMeasurePattern = `-?[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)`
var ST_UniversalMeasurePatternRe = regexp.MustCompile(ST_UniversalMeasurePattern)
const ST_PositiveUniversalMeasurePattern = `[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)`
var ST_PositiveUniversalMeasurePatternRe = regexp.MustCompile(ST_PositiveUniversalMeasurePattern)
const ST_PercentagePattern = `-?[0-9]+(\.[0-9]+)?%`
var ST_PercentagePatternRe = regexp.MustCompile(ST_PercentagePattern)
const ST_FixedPercentagePattern = `-?((100)|([0-9][0-9]?))(\.[0-9][0-9]?)?%`
var ST_FixedPercentagePatternRe = regexp.MustCompile(ST_FixedPercentagePattern)
const ST_PositivePercentagePattern = `[0-9]+(\.[0-9]+)?%`
var ST_PositivePercentagePatternRe = regexp.MustCompile(ST_PositivePercentagePattern)
const ST_PositiveFixedPercentagePattern = `((100)|([0-9][0-9]?))(\.[0-9][0-9]?)?%`
var ST_PositiveFixedPercentagePatternRe = regexp.MustCompile(ST_PositiveFixedPercentagePattern)
func ParseUnionST_OnOff(s string) (ST_OnOff, error) {
r := ST_OnOff{}
switch s {
case "true", "1", "on":
tru := true
r.Bool = &tru
default:
fals := false
r.Bool = &fals
}
return r, nil
}
func b2i(b bool) uint8 {
if b {
return 1
}
return 0
}
type ST_CalendarType byte
const (
ST_CalendarTypeUnset ST_CalendarType = 0
ST_CalendarTypeGregorian ST_CalendarType = 1
ST_CalendarTypeGregorianUs ST_CalendarType = 2
ST_CalendarTypeGregorianMeFrench ST_CalendarType = 3
ST_CalendarTypeGregorianArabic ST_CalendarType = 4
ST_CalendarTypeHijri ST_CalendarType = 5
ST_CalendarTypeHebrew ST_CalendarType = 6
ST_CalendarTypeTaiwan ST_CalendarType = 7
ST_CalendarTypeJapan ST_CalendarType = 8
ST_CalendarTypeThai ST_CalendarType = 9
ST_CalendarTypeKorea ST_CalendarType = 10
ST_CalendarTypeSaka ST_CalendarType = 11
ST_CalendarTypeGregorianXlitEnglish ST_CalendarType = 12
ST_CalendarTypeGregorianXlitFrench ST_CalendarType = 13
ST_CalendarTypeNone ST_CalendarType = 14
)
func (e ST_CalendarType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{}
attr.Name = name
switch e {
case ST_CalendarTypeUnset:
attr.Value = ""
case ST_CalendarTypeGregorian:
attr.Value = "gregorian"
case ST_CalendarTypeGregorianUs:
attr.Value = "gregorianUs"
case ST_CalendarTypeGregorianMeFrench:
attr.Value = "gregorianMeFrench"
case ST_CalendarTypeGregorianArabic:
attr.Value = "gregorianArabic"
case ST_CalendarTypeHijri:
attr.Value = "hijri"
case ST_CalendarTypeHebrew:
attr.Value = "hebrew"
case ST_CalendarTypeTaiwan:
attr.Value = "taiwan"
case ST_CalendarTypeJapan:
attr.Value = "japan"
case ST_CalendarTypeThai:
attr.Value = "thai"
case ST_CalendarTypeKorea:
attr.Value = "korea"
case ST_CalendarTypeSaka:
attr.Value = "saka"
case ST_CalendarTypeGregorianXlitEnglish:
attr.Value = "gregorianXlitEnglish"
case ST_CalendarTypeGregorianXlitFrench:
attr.Value = "gregorianXlitFrench"
case ST_CalendarTypeNone:
attr.Value = "none"
}
return attr, nil
}
func (e *ST_CalendarType) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "":
*e = 0
case "gregorian":
*e = 1
case "gregorianUs":
*e = 2
case "gregorianMeFrench":
*e = 3
case "gregorianArabic":
*e = 4
case "hijri":
*e = 5
case "hebrew":
*e = 6
case "taiwan":
*e = 7
case "japan":
*e = 8
case "thai":
*e = 9
case "korea":
*e = 10
case "saka":
*e = 11
case "gregorianXlitEnglish":
*e = 12
case "gregorianXlitFrench":
*e = 13
case "none":
*e = 14
}
return nil
}
func (m ST_CalendarType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(m.String(), start)
}
func (m *ST_CalendarType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
tok, err := d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
*m = 1
return nil
}
if cd, ok := tok.(xml.CharData); !ok {
return fmt.Errorf("expected char data, got %T", tok)
} else {
switch string(cd) {
case "":
*m = 0
case "gregorian":
*m = 1
case "gregorianUs":
*m = 2
case "gregorianMeFrench":
*m = 3
case "gregorianArabic":
*m = 4
case "hijri":
*m = 5
case "hebrew":
*m = 6
case "taiwan":
*m = 7
case "japan":
*m = 8
case "thai":
*m = 9
case "korea":
*m = 10
case "saka":
*m = 11
case "gregorianXlitEnglish":
*m = 12
case "gregorianXlitFrench":
*m = 13
case "none":
*m = 14
}
}
tok, err = d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
return nil
}
return fmt.Errorf("expected end element, got %v", tok)
}
func (m ST_CalendarType) String() string {
switch m {
case 0:
return ""
case 1:
return "gregorian"
case 2:
return "gregorianUs"
case 3:
return "gregorianMeFrench"
case 4:
return "gregorianArabic"
case 5:
return "hijri"
case 6:
return "hebrew"
case 7:
return "taiwan"
case 8:
return "japan"
case 9:
return "thai"
case 10:
return "korea"
case 11:
return "saka"
case 12:
return "gregorianXlitEnglish"
case 13:
return "gregorianXlitFrench"
case 14:
return "none"
}
return ""
}
func (m ST_CalendarType) Validate() error {
return m.ValidateWithPath("")
}
func (m ST_CalendarType) ValidateWithPath(path string) error {
switch m {
case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14:
default:
return fmt.Errorf("%s: out of range value %d", path, int(m))
}
return nil
}
type ST_AlgClass byte
const (
ST_AlgClassUnset ST_AlgClass = 0
ST_AlgClassHash ST_AlgClass = 1
ST_AlgClassCustom ST_AlgClass = 2
)
func (e ST_AlgClass) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{}
attr.Name = name
switch e {
case ST_AlgClassUnset:
attr.Value = ""
case ST_AlgClassHash:
attr.Value = "hash"
case ST_AlgClassCustom:
attr.Value = "custom"
}
return attr, nil
}
func (e *ST_AlgClass) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "":
*e = 0
case "hash":
*e = 1
case "custom":
*e = 2
}
return nil
}
func (m ST_AlgClass) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(m.String(), start)
}
func (m *ST_AlgClass) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
tok, err := d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
*m = 1
return nil
}
if cd, ok := tok.(xml.CharData); !ok {
return fmt.Errorf("expected char data, got %T", tok)
} else {
switch string(cd) {
case "":
*m = 0
case "hash":
*m = 1
case "custom":
*m = 2
}
}
tok, err = d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
return nil
}
return fmt.Errorf("expected end element, got %v", tok)
}
func (m ST_AlgClass) String() string {
switch m {
case 0:
return ""
case 1:
return "hash"
case 2:
return "custom"
}
return ""
}
func (m ST_AlgClass) Validate() error {
return m.ValidateWithPath("")
}
func (m ST_AlgClass) ValidateWithPath(path string) error {
switch m {
case 0, 1, 2:
default:
return fmt.Errorf("%s: out of range value %d", path, int(m))
}
return nil
}
type ST_CryptProv byte
const (
ST_CryptProvUnset ST_CryptProv = 0
ST_CryptProvRsaAES ST_CryptProv = 1
ST_CryptProvRsaFull ST_CryptProv = 2
ST_CryptProvCustom ST_CryptProv = 3
)
func (e ST_CryptProv) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{}
attr.Name = name
switch e {
case ST_CryptProvUnset:
attr.Value = ""
case ST_CryptProvRsaAES:
attr.Value = "rsaAES"
case ST_CryptProvRsaFull:
attr.Value = "rsaFull"
case ST_CryptProvCustom:
attr.Value = "custom"
}
return attr, nil
}
func (e *ST_CryptProv) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "":
*e = 0
case "rsaAES":
*e = 1
case "rsaFull":
*e = 2
case "custom":
*e = 3
}
return nil
}
func (m ST_CryptProv) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(m.String(), start)
}
func (m *ST_CryptProv) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
tok, err := d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
*m = 1
return nil
}
if cd, ok := tok.(xml.CharData); !ok {
return fmt.Errorf("expected char data, got %T", tok)
} else {
switch string(cd) {
case "":
*m = 0
case "rsaAES":
*m = 1
case "rsaFull":
*m = 2
case "custom":
*m = 3
}
}
tok, err = d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
return nil
}
return fmt.Errorf("expected end element, got %v", tok)
}
func (m ST_CryptProv) String() string {
switch m {
case 0:
return ""
case 1:
return "rsaAES"
case 2:
return "rsaFull"
case 3:
return "custom"
}
return ""
}
func (m ST_CryptProv) Validate() error {
return m.ValidateWithPath("")
}
func (m ST_CryptProv) ValidateWithPath(path string) error {
switch m {
case 0, 1, 2, 3:
default:
return fmt.Errorf("%s: out of range value %d", path, int(m))
}
return nil
}
type ST_AlgType byte
const (
ST_AlgTypeUnset ST_AlgType = 0
ST_AlgTypeTypeAny ST_AlgType = 1
ST_AlgTypeCustom ST_AlgType = 2
)
func (e ST_AlgType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{}
attr.Name = name
switch e {
case ST_AlgTypeUnset:
attr.Value = ""
case ST_AlgTypeTypeAny:
attr.Value = "typeAny"
case ST_AlgTypeCustom:
attr.Value = "custom"
}
return attr, nil
}
func (e *ST_AlgType) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "":
*e = 0
case "typeAny":
*e = 1
case "custom":
*e = 2
}
return nil
}
func (m ST_AlgType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(m.String(), start)
}
func (m *ST_AlgType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
tok, err := d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
*m = 1
return nil
}
if cd, ok := tok.(xml.CharData); !ok {
return fmt.Errorf("expected char data, got %T", tok)
} else {
switch string(cd) {
case "":
*m = 0
case "typeAny":
*m = 1
case "custom":
*m = 2
}
}
tok, err = d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
return nil
}
return fmt.Errorf("expected end element, got %v", tok)
}
func (m ST_AlgType) String() string {
switch m {
case 0:
return ""
case 1:
return "typeAny"
case 2:
return "custom"
}
return ""
}
func (m ST_AlgType) Validate() error {
return m.ValidateWithPath("")
}
func (m ST_AlgType) ValidateWithPath(path string) error {
switch m {
case 0, 1, 2:
default:
return fmt.Errorf("%s: out of range value %d", path, int(m))
}
return nil
}
type ST_OnOff1 byte
const (
ST_OnOff1Unset ST_OnOff1 = 0
ST_OnOff1On ST_OnOff1 = 1
ST_OnOff1Off ST_OnOff1 = 2
)
func (e ST_OnOff1) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{}
attr.Name = name
switch e {
case ST_OnOff1Unset:
attr.Value = ""
case ST_OnOff1On:
attr.Value = "on"
case ST_OnOff1Off:
attr.Value = "off"
}
return attr, nil
}
func (e *ST_OnOff1) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "":
*e = 0
case "on":
*e = 1
case "off":
*e = 2
}
return nil
}
func (m ST_OnOff1) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(m.String(), start)
}
func (m *ST_OnOff1) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
tok, err := d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
*m = 1
return nil
}
if cd, ok := tok.(xml.CharData); !ok {
return fmt.Errorf("expected char data, got %T", tok)
} else {
switch string(cd) {
case "":
*m = 0
case "on":
*m = 1
case "off":
*m = 2
}
}
tok, err = d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
return nil
}
return fmt.Errorf("expected end element, got %v", tok)
}
func (m ST_OnOff1) String() string {
switch m {
case 0:
return ""
case 1:
return "on"
case 2:
return "off"
}
return ""
}
func (m ST_OnOff1) Validate() error {
return m.ValidateWithPath("")
}
func (m ST_OnOff1) ValidateWithPath(path string) error {
switch m {
case 0, 1, 2:
default:
return fmt.Errorf("%s: out of range value %d", path, int(m))
}
return nil
}
type ST_TrueFalse byte
const (
ST_TrueFalseUnset ST_TrueFalse = 0
ST_TrueFalseT ST_TrueFalse = 1
ST_TrueFalseF ST_TrueFalse = 2
ST_TrueFalseTrue ST_TrueFalse = 3
ST_TrueFalseFalse ST_TrueFalse = 4
)
func (e ST_TrueFalse) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{}
attr.Name = name
switch e {
case ST_TrueFalseUnset:
attr.Value = ""
case ST_TrueFalseT:
attr.Value = "t"
case ST_TrueFalseF:
attr.Value = "f"
case ST_TrueFalseTrue:
attr.Value = "true"
case ST_TrueFalseFalse:
attr.Value = "false"
}
return attr, nil
}
func (e *ST_TrueFalse) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "":
*e = 0
case "t":
*e = 1
case "f":
*e = 2
case "true":
*e = 3
case "false":
*e = 4
}
return nil
}
func (m ST_TrueFalse) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(m.String(), start)
}
func (m *ST_TrueFalse) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
tok, err := d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
*m = 1
return nil
}
if cd, ok := tok.(xml.CharData); !ok {
return fmt.Errorf("expected char data, got %T", tok)
} else {
switch string(cd) {
case "":
*m = 0
case "t":
*m = 1
case "f":
*m = 2
case "true":
*m = 3
case "false":
*m = 4
}
}
tok, err = d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
return nil
}
return fmt.Errorf("expected end element, got %v", tok)
}
func (m ST_TrueFalse) String() string {
switch m {
case 0:
return ""
case 1:
return "t"
case 2:
return "f"
case 3:
return "true"
case 4:
return "false"
}
return ""
}
func (m ST_TrueFalse) Validate() error {
return m.ValidateWithPath("")
}
func (m ST_TrueFalse) ValidateWithPath(path string) error {
switch m {
case 0, 1, 2, 3, 4:
default:
return fmt.Errorf("%s: out of range value %d", path, int(m))
}
return nil
}
type ST_TrueFalseBlank byte
const (
ST_TrueFalseBlankUnset ST_TrueFalseBlank = 0
ST_TrueFalseBlankT ST_TrueFalseBlank = 1
ST_TrueFalseBlankF ST_TrueFalseBlank = 2
ST_TrueFalseBlankTrue ST_TrueFalseBlank = 3
ST_TrueFalseBlankFalse ST_TrueFalseBlank = 4
ST_TrueFalseBlankTrue_ ST_TrueFalseBlank = 6
ST_TrueFalseBlankFalse_ ST_TrueFalseBlank = 7
)
func (e ST_TrueFalseBlank) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{}
attr.Name = name
switch e {
case ST_TrueFalseBlankUnset:
attr.Value = ""
case ST_TrueFalseBlankT:
attr.Value = "t"
case ST_TrueFalseBlankF:
attr.Value = "f"
case ST_TrueFalseBlankTrue:
attr.Value = "true"
case ST_TrueFalseBlankFalse:
attr.Value = "false"
case ST_TrueFalseBlankTrue_:
attr.Value = "True"
case ST_TrueFalseBlankFalse_:
attr.Value = "False"
}
return attr, nil
}
func (e *ST_TrueFalseBlank) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "":
*e = 0
case "t":
*e = 1
case "f":
*e = 2
case "true":
*e = 3
case "false":
*e = 4
case "True":
*e = 6
case "False":
*e = 7
}
return nil
}
func (m ST_TrueFalseBlank) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(m.String(), start)
}
func (m *ST_TrueFalseBlank) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
tok, err := d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
*m = 1
return nil
}
if cd, ok := tok.(xml.CharData); !ok {
return fmt.Errorf("expected char data, got %T", tok)
} else {
switch string(cd) {
case "":
*m = 0
case "t":
*m = 1
case "f":
*m = 2
case "true":
*m = 3
case "false":
*m = 4
case "True":
*m = 6
case "False":
*m = 7
}
}
tok, err = d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
return nil
}
return fmt.Errorf("expected end element, got %v", tok)
}
func (m ST_TrueFalseBlank) String() string {
switch m {
case 0:
return ""
case 1:
return "t"
case 2:
return "f"
case 3:
return "true"
case 4:
return "false"
case 6:
return "True"
case 7:
return "False"
}
return ""
}
func (m ST_TrueFalseBlank) Validate() error {
return m.ValidateWithPath("")
}
func (m ST_TrueFalseBlank) ValidateWithPath(path string) error {
switch m {
case 0, 1, 2, 3, 4, 6, 7:
default:
return fmt.Errorf("%s: out of range value %d", path, int(m))
}
return nil
}
type ST_VerticalAlignRun byte
const (
ST_VerticalAlignRunUnset ST_VerticalAlignRun = 0
ST_VerticalAlignRunBaseline ST_VerticalAlignRun = 1
ST_VerticalAlignRunSuperscript ST_VerticalAlignRun = 2
ST_VerticalAlignRunSubscript ST_VerticalAlignRun = 3
)
func (e ST_VerticalAlignRun) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{}
attr.Name = name
switch e {
case ST_VerticalAlignRunUnset:
attr.Value = ""
case ST_VerticalAlignRunBaseline:
attr.Value = "baseline"
case ST_VerticalAlignRunSuperscript:
attr.Value = "superscript"
case ST_VerticalAlignRunSubscript:
attr.Value = "subscript"
}
return attr, nil
}
func (e *ST_VerticalAlignRun) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "":
*e = 0
case "baseline":
*e = 1
case "superscript":
*e = 2
case "subscript":
*e = 3
}
return nil
}
func (m ST_VerticalAlignRun) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(m.String(), start)
}
func (m *ST_VerticalAlignRun) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
tok, err := d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
*m = 1
return nil
}
if cd, ok := tok.(xml.CharData); !ok {
return fmt.Errorf("expected char data, got %T", tok)
} else {
switch string(cd) {
case "":
*m = 0
case "baseline":
*m = 1
case "superscript":
*m = 2
case "subscript":
*m = 3
}
}
tok, err = d.Token()
if err != nil {
return err
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
return nil
}
return fmt.Errorf("expected end element, got %v", tok)
}
func (m ST_VerticalAlignRun) String() string {
switch m {
case 0:
return ""
case 1:
return "baseline"
case 2:
return "superscript"
case 3:
return "subscript"
}
return ""
}
func (m ST_VerticalAlignRun) Validate() error {
return m.ValidateWithPath("")
}
func (m ST_VerticalAlignRun) ValidateWithPath(path string) error {
switch m {
case 0, 1, 2, 3:
default:
return fmt.Errorf("%s: out of range value %d", path, int(m))
}
return nil
}
type ST_XAlign byte
const (