Skip to content

RelaxNG autocomplete not respecting choice tag #1107

@AndrewJayStudio

Description

@AndrewJayStudio

In example.rng I have the code:

<define name="key.element">
    <element name="key">
        <attribute name="name">
            <ref name="keyname.type"/>
        </attribute>
        <ref name="structured.content"/>
    </element>
</define>

<define name="structured.content">
        <choice>
            <group>
                <attribute name="type">
                    <value>dict</value>
                </attribute>
                <zeroOrMore>
                    <element name="key">
                        <attribute name="name">
                            <ref name="keyname.type"/>
                        </attribute>
                        <ref name="structured.content"/>
                    </element>
                </zeroOrMore>
            </group>
            <group>
                <attribute name="type">
                    <value>arr</value>
                </attribute>
                <zeroOrMore>
                    <element name="item">
                        <ref name="structured.content"/>
                    </element>
                </zeroOrMore>
            </group>
            <group>
                <attribute name="type">
                    <value>name</value>
                </attribute>
                <ref name="keyname.type"/>
            </group>
            <group>
                <attribute name="type">
                    <value>null</value>
                </attribute>
            </group>
            <group>
                <attribute name="type">
                    <value>bool</value>
                </attribute>
                <choice>
                    <value>true</value>
                    <value>false</value>
                </choice>
            </group>
            <group>
                <attribute name="type">
                    <value>int</value>
                </attribute>
                <data type="int"/>
            </group>
            <group>
                <attribute name="type">
                    <value>num</value>
                </attribute>
                <data type="decimal"/>
            </group>
            <group>
                <attribute name="type">
                    <value>str</value>
                </attribute>
                <data type="string"/>
            </group>
        </choice>
    </define>

Which when trying to autocomplete in XML document, produces the following result:

<key name="" type="dict" type="arr" type="name" type="null" type="bool" type="int" type="num" type="str"></key>

This is unexpected, as it shouldn't be combining all the mutually exclusive choice operands. The expected result should at the very least not auto fill the attributes of <key/> and instead leave them as auto suggestions upon typing. The best case scenario would have something similar to <key name="" type=""></key> with tab-able auto suggestions between the attribute values. The validation itself recognizes that the produced result is invalid, giving Attribute "type" was already specified for element "key".xml(AttributeNotUnique).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions