Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Wrapped list attribute naming questions: wrapped or wrapper element name? #1207

Unanswered
kenmalton asked this question in Q&A
Discussion options

Hello, I've been doing a deep dive into xsdata recently to assess its suitability for a project that I am working on. I think it looks like a wonderful library, thank you and well done!

I have some questions regarding wrapped lists and how the list's attribute is named on the generated dataclass. Questions are at the bottom after some introduction:

  1. On the Wrapped List documentation page it implies that the attribute should be named after the wrapper element - "Books" in this case.

  2. On the wrapperfields config documentation it shows that the attribute will be named after the wrapped element - "alpha", "bravo", "charlie" (singular). This is the implemented behaviour.

I think I prefer the first approach - partly because it feels more intuitive that the list attribute should have the plural name from the wrapped element, but also because it would make this document structure possible...

<Library>
 <BestBooks>
 <Title>python for beginners</Title>
 <Title>beautiful xml</Title>
 </BestBooks>
 <WorstBooks>
 <Title>python for nobody</Title>
 <Title>horrible xml</Title>
 </WorstBooks>
</Library>

I would like to know:

  • is the current behaviour based on a principled decision, or an accident of implementation?
  • I think I can get my preferred behaviour through monkeypatching the CreateWrapperFields.wrap_field method, but I don't know if that's a good idea and wonder if there is a better way?
  • what would you think about making this configurable?

Thanks!

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /