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

XSD based Autocompletion for substitutionGroup #825

Closed
shubham-m opened this issue Nov 28, 2022 · 3 comments · Fixed by eclipse/lemminx#1386
Closed

XSD based Autocompletion for substitutionGroup #825

shubham-m opened this issue Nov 28, 2022 · 3 comments · Fixed by eclipse/lemminx#1386
Labels
bug Something isn't working completion
Milestone

Comments

@shubham-m
Copy link

shubham-m commented Nov 28, 2022

Sample XSD - bookstore.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <!-- ELEMENT DECLARATIONS -->

    <xsd:element name="Name" type="xsd:string" />
    <xsd:element name="StoreName" substitutionGroup="Name" type="MyString" />

    <xsd:element name="Publication" type="PublicationType" />
    <xsd:element name="Book" substitutionGroup="Publication" type="BookType" />
    <xsd:element name="Magazine" substitutionGroup="Publication" type="MagazineType" />

    <xsd:element name="BookStore">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Name" />
                <xsd:element ref="Publication" maxOccurs="unbounded" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="LiteratureStore" substitutionGroup="BookStore" />


    <!--  TYPE DEFINITIONS -->

    <xsd:simpleType name="MyString">
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="3"></xsd:minLength>
            <xsd:maxLength value="10"></xsd:maxLength>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="PublicationType">
        <xsd:sequence>
            <xsd:element name="Title" type="xsd:string" />
            <xsd:element name="Author" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
            <xsd:element name="Date" type="xsd:gYear" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="BookType">
        <xsd:complexContent>
            <xsd:extension base="PublicationType">
                <xsd:sequence>
                    <xsd:element name="ISBN" type="xsd:string" />
                    <xsd:element name="Publisher" type="xsd:string" />
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="MagazineType">
        <xsd:complexContent>
            <xsd:restriction base="PublicationType">
                <xsd:sequence>
                    <xsd:element name="Title" type="xsd:string" />
                    <xsd:element name="Date" type="xsd:gYear" />
                </xsd:sequence>
            </xsd:restriction>
        </xsd:complexContent>
    </xsd:complexType>

</xsd:schema>

Here Book extends Publication, but for auto complete the elements inside Book are not shown in autocomplete.

Screenshot 2022-11-28 at 9 23 07 PM

The quick fix tooltip is suggesting the elements but auto complete is not providing them. Clicking on Quick fix is also not helping

Screenshot 2022-11-28 at 9 23 01 PM

@fbricon fbricon added the enhancement New feature or request label Nov 28, 2022
@angelozerr
Copy link
Contributor

@shubham-m could you share please your xml.

@shubham-m
Copy link
Author

shubham-m commented Nov 28, 2022

Sample XML to reproduce the problem. bookstore.xml ->

<?xml version="1.0" encoding="UTF-8"?>
<BookStore 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="bookstore.xsd">
    <StoreName>ABC Store</StoreName>
    <Publication>
        <Title>Book1</Title>
        <Author>Author1</Author>
        <!-- Autocomplete works here on the base element, try adding another author -->
        <Date>2022</Date>
    </Publication>
    <!-- VSCode Redhat XML plugin shows error here at book element -->
    <Book>
        <!-- Unable to add elements here using auto complete -->
    </Book>
</BookStore>

@angelozerr angelozerr added bug Something isn't working completion and removed enhancement New feature or request labels Nov 30, 2022
angelozerr pushed a commit to angelozerr/lemminx that referenced this issue Nov 30, 2022
@angelozerr
Copy link
Contributor

@shubham-m I created a PR to fix this issue. See demo at eclipse/lemminx#1386 (comment)

@datho7561 datho7561 added this to the 0.23.0 milestone Nov 30, 2022
datho7561 pushed a commit to eclipse/lemminx that referenced this issue Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working completion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants