File: README.md

package info (click to toggle)
python-xmlschema 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,208 kB
  • sloc: python: 39,174; xml: 1,282; makefile: 36
file content (31 lines) | stat: -rw-r--r-- 1,048 bytes parent folder | download | duplicates (4)
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
From [issue #22](https://github.com/brunato/xmlschema/issues/22#issuecomment-345236067).

Core of the issue is described as follows:

> One thing I noticed is that the to_dict function is not consistent in how it
> creates values in the dictionary for sequences. The sequence can already be
> anticipated from the .xsd, so I would have expected those values to be within
> array structures no matter the number of sequence elements present in the
> parent xml element.

See xsd in `./xsd_string.xsd`.

See xml in `./xml_string_1.xml` and `./xml_string_2.xml`.

```` python
import xmlschema
xsd_schema = xmlschema.XMLSchema(xsd_string)
xml_data_1 = xsd_schema.to_dict(xml_string_1)
xml_data_2 = xsd_schema.to_dict(xml_string_2)
print(xml_data_1)

    {'bar':
      {'@name': 'bar_1', 'subject_name': 'Bar #1'}}
print(xml_data_2)

    {'bar':
      [{'@name': 'bar_1', 'subject_name': 'Bar #1'},
       {'@name': 'bar_2', 'subject_name': 'Bar #2'}]}
````

We would expect the output from each to contain a list; The first a list with one dictionary.