Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

XML: Allow children of ElementSpec to also be ElementSpec #1590

Open

Description

@Mafus1

I would like to provide auto complete for children of elements, where the name of the children is not unique.

In the example below, the elements infos are used for cars and bikes, but are completely different types of information. XSD allows this by specifying a type for an element as well as a name.

<car>
  <infos>
    <cc>3000</cc>
  </infos>
</car>
<bike>
  <infos>
    <gears>21</gears>
  </infos>
</bike>

Since I can only define an array of names as the children of ElementSpec, it is not possible to have a infos element that is different for cars vs. bikes.

I would suggest expanding the children property to be of type: (string | ElementSpec)[], or allow a child to be a reference to a type, not just a name.

Is that something you are willing to implement?

Activity

  1. marijnh commented on Jul 18, 2025

    @marijnh
    Member

    When completing, the code currently only looks at the name of the surrounding element. To support what you're proposing, it'd have to trace the set of parents all the way from the root element to figure out what context it is in. This is possible but adds quite a bit of complexity and new failure modes (such as parent elements being missing of malformed). As such, I'm not sure this would be an improvement.

  2. Mafus1 commented on Jul 21, 2025

    @Mafus1
    Author

    I understand the complexity that this would add. But, I'm not sure how I would be able to support anything but the simplest schema with the current approach. Maybe I'm missing something? Do you have a suggestion how I could implement my example, besides changing the name of infos to car-infos and bike-infos or something similar?

  3. marijnh commented on Apr 15, 2026

    @marijnh
    Member

    This issue has been moved to issue #1590 on the repository's new home.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions