This repository was archived by the owner on Oct 7, 2024. It is now read-only.
File tree 2 files changed +12
-7
lines changed
2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 147
147
(fault-template [this])
148
148
(parse-fault [this fault-xml]))
149
149
150
- (defn- content->fields [content type]
150
+ (defn- content->fields [content type optional? enumeration ]
151
151
(let [content (filter #(not (string/starts-with? % " \n " )) content)]
152
152
(loop [el (first content) els (rest content) comments [] fields []]
153
153
(if-not el
154
154
fields
155
155
(cond
156
156
(string? el)
157
- {:__value nil
158
- :__type type}
157
+ {:__value
158
+ (cond-> {:__type type}
159
+ optional? (merge {:__optional? true })
160
+ enumeration (merge {:__enum enumeration}))}
159
161
160
162
(instance? Comment el)
161
163
(recur (first els) (rest els) (conj comments (:content el)) fields)
177
179
original-xml]
178
180
(let [{:keys [type min-occurs max-occurs
179
181
optional enumeration]} (into {} (map parse-comment comments))
180
- fields (content->fields content type)]
182
+ fields (content->fields content
183
+ type
184
+ (or optional (= min-occurs 0 ))
185
+ enumeration)]
181
186
(reify
182
187
Element
183
188
(get-original [_] original-xml)
227
232
(filter (fn [[_ attrv]]
228
233
(= " ?" attrv)))
229
234
(map (fn [[attr-name _]]
230
- [(fix-fn attr-name) {:__value nil
231
- :__type " string" }]))
235
+ [(fix-fn attr-name) {:__value {:__type " string" }}]))
232
236
(into {})))]
233
237
{:__attrs attrs}
234
238
{})
Original file line number Diff line number Diff line change 26
26
<book : ComplexObjectWithComplexTag >
27
27
<!-- 1 or more repetitions:-->
28
28
<BookId BookType =" ?" >
29
- <!-- type: string-->
29
+ <!-- type: string - enumeration: [FOO_ID,BAR_ID]-->
30
+ <!-- Optional: true-->
30
31
<ID >?</ID >
31
32
<Type >
32
33
<!-- type: integer-->
You can’t perform that action at this time.
0 commit comments