1
- use crate :: xsd:: { element:: Element , Implementation , XsdContext } ;
1
+ use crate :: xsd:: { choice :: Choice , element:: Element , Implementation , XsdContext } ;
2
2
use log:: { debug, info} ;
3
3
use proc_macro2:: TokenStream ;
4
4
use std:: io:: prelude:: * ;
@@ -9,6 +9,8 @@ use yaserde::YaDeserialize;
9
9
pub struct Sequence {
10
10
#[ yaserde( rename = "element" ) ]
11
11
pub elements : Vec < Element > ,
12
+ #[ yaserde( rename = "choice" ) ]
13
+ pub choices : Vec < Choice > ,
12
14
}
13
15
14
16
impl Implementation for Sequence {
@@ -19,11 +21,22 @@ impl Implementation for Sequence {
19
21
context : & XsdContext ,
20
22
) -> TokenStream {
21
23
info ! ( "Generate elements" ) ;
22
- self
24
+ let elements : TokenStream = self
23
25
. elements
24
26
. iter ( )
25
27
. map ( |element| element. get_field_implementation ( context, prefix, false , false ) )
26
- . collect ( )
28
+ . collect ( ) ;
29
+
30
+ let choices: TokenStream = self
31
+ . choices
32
+ . iter ( )
33
+ . map ( |choice| choice. get_field_implementation ( context, prefix) )
34
+ . collect ( ) ;
35
+
36
+ quote ! (
37
+ #elements
38
+ #choices
39
+ )
27
40
}
28
41
}
29
42
@@ -47,10 +60,21 @@ impl Sequence {
47
60
context : & XsdContext ,
48
61
prefix : & Option < String > ,
49
62
) -> TokenStream {
50
- self
63
+ let elements : TokenStream = self
51
64
. elements
52
65
. iter ( )
53
- . map ( |element| element. get_field_implementation ( context, prefix, true , false ) )
54
- . collect ( )
66
+ . map ( |element| element. get_field_implementation ( context, prefix, false , false ) )
67
+ . collect ( ) ;
68
+
69
+ let choices: TokenStream = self
70
+ . choices
71
+ . iter ( )
72
+ . map ( |choice| choice. get_field_implementation ( context, prefix) )
73
+ . collect ( ) ;
74
+
75
+ quote ! (
76
+ #elements
77
+ #choices
78
+ )
55
79
}
56
80
}
0 commit comments