Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for a wrapped list #709

Closed
cercide opened this issue Sep 11, 2022 · 0 comments · Fixed by #710
Closed

Support for a wrapped list #709

cercide opened this issue Sep 11, 2022 · 0 comments · Fixed by #710

Comments

@cercide
Copy link
Contributor

cercide commented Sep 11, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant