xsdata
xsdata copied to clipboard
Support for a wrapped list
XML data structures commonly wrap element and primitive collections. For instance, a library may have some books and magazines as well; exemplified below.
<Library>
<Books>
<Book>book 1</Book>
<Book>book 2</Book>
</Books>
<Magazines>
<Magazine>book 1</Magazine>
<Magazine>book 2</Magazine>
</Magazines>
</Library>
Currently, xsdata requires an additional wrapper class to represent this data structure.
@dataclass
class Book:
title: str = field( metadata={"type": "Text"})
@dataclass
class Books:
books: List[Book]
@dataclass
class Library:
books: Books
Obviously, the wrapper class Books does not have any meaning and bloats the source code . It would be a great thing if xsdata would support wrapped data structures by using just a keyword at a fields metadata.