Skip to content

Merge attribute suggestions based on relax-ng schema #1022

Open
@andershol

Description

If I have a relax-ng schema like this, where a "Items"-root element, can have "Item"-sub-elements, all having a "Type"-attribute, that determines if it is a Foo-Item or and Bar-Item, and that in turn determines their sub-elements (having the contents of an element be determined by an attribute is a reason for using relax-ng as xsd 1.1 is not yet supported):

<grammar xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
    <element name="Items">
      <element name="Item">
        <choice>
          <group>
            <attribute name="Type"><value>Foo</value></attribute>
            <attribute name="FooAttr"/>
          </group>
          <group>
            <attribute name="Type"><value>Bar</value></attribute>
            <attribute name="BarAttr"/>
          </group>
        </choice>
      </element>
    </element>
  </start>
</grammar>

I can have a document like this:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="test.rng"?>
<Items>
  <Item ></Item>
</Items>

I get a warning that Item is missing a Type-attrubte, which is good and correct.

But if I place the cursor after "<Item " (i.e. a space after "Item") and press Ctrl+Space to get suggestions, I get a list containing "BarAttr", "FooAttr", "Type", and "Type" (i.e. "Type" appears twice). Choosing the first "Type", attribute is inserted with the value "Foo" and it appears to be the only allowed value, while choosing the second "Type" inserts the attribute with "Bar" as the only allowed value. I would have liked only one "Type" attributes in the list with the choice of either "Foo" or "Bar" as the value.

Also, what is probably just another symptom of the same problem is, that if I remove the Item-element and put the cursor inside the empty Items-element, and write "<I" and enter (to accept the suggestion of "Item") <Item Type="Foo" Type="Bar"></Item> is inserted which is invalid xml. I would have linked to see just an single Type-attribute with the choice of "Foo" and "Bar" as the value.

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