Debian Codegraph @

tests/test_cases/issues/issue_022/README.md

raw
1 From [issue #22](https://github.com/brunato/xmlschema/issues/22#issuecomment-345236067).
2
3 Core of the issue is described as follows:
4
5 > One thing I noticed is that the to_dict function is not consistent in how it
6 > creates values in the dictionary for sequences. The sequence can already be
7 > anticipated from the .xsd, so I would have expected those values to be within
8 > array structures no matter the number of sequence elements present in the
9 > parent xml element.
10
11 See xsd in `./xsd_string.xsd`.
12
13 See xml in `./xml_string_1.xml` and `./xml_string_2.xml`.
14
15 ```` python
16 import xmlschema
17 xsd_schema = xmlschema.XMLSchema(xsd_string)
18 xml_data_1 = xsd_schema.to_dict(xml_string_1)
19 xml_data_2 = xsd_schema.to_dict(xml_string_2)
20 print(xml_data_1)
21
22 {'bar':
23 {'@name': 'bar_1', 'subject_name': 'Bar #1'}}
24 print(xml_data_2)
25
26 {'bar':
27 [{'@name': 'bar_1', 'subject_name': 'Bar #1'},
28 {'@name': 'bar_2', 'subject_name': 'Bar #2'}]}
29 ````
30
31 We would expect the output from each to contain a list; The first a list with one dictionary.