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

Setting Attributes on Parent with Children as Array #624

Open
jansule opened this issue Aug 16, 2021 · 0 comments
Open

Setting Attributes on Parent with Children as Array #624

jansule opened this issue Aug 16, 2021 · 0 comments

Comments

@jansule
Copy link

jansule commented Aug 16, 2021

When building from objects, it is currently either possible to set a specific order for child elements, or to set attributes on the parent. However, it is not possible to do both, i.e. having an ordered set of children, while also providing attributes for the parent node.

Example: Set specific order for child elements, but no attribute on parent

builder.buildObject({Parent: [[{Literal: 'foo'}, {PropertyName: 'bar'}, {Literal: 'baz'}]]});
<Parent>
  <Literal>foo<Literal>
  <PropertyName>bar</PropertyName>
  <Literal>baz<Literal>
</Parent>

Example: Set attributes on parent element, but lose order for child elements

builder.buildObject({Parent: {$: {name: 'faz'}, Literal: ['foo', 'baz'], PropertyName: ['bar']}});
<Parent name="faz">
  <Literal>foo<Literal>
  <Literal>baz<Literal>
  <PropertyName>bar</PropertyName>
</Parent>

It would be nice, though, to be able to setting attributes on the parent element as well as preserving the explicit order of the child elements. So that we can create the following:

<Parent name="faz">
  <Literal>foo<Literal>
  <PropertyName>bar</PropertyName>
  <Literal>baz<Literal>
</Parent>
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

No branches or pull requests

1 participant