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

Fix xsd:extension to extend the base type with its elements.#46

Merged
pleonex merged 1 commit intopleonex:masterfrom
ph777:fix/extensions
Jun 4, 2018
Merged

Fix xsd:extension to extend the base type with its elements.#46
pleonex merged 1 commit intopleonex:masterfrom
ph777:fix/extensions

Conversation

@ph777
Copy link

@ph777 ph777 commented May 25, 2018

Consider the following schema that extends complex types:

<xs:complexType name="baseType">
        <xs:sequence>
            <xs:element name="a" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="extendedType">
        <xs:complexContent>
            <xs:extension base="baseType">
                <xs:sequence>
                    <xs:element name="b" type="xs:string"/>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="superExtendedType">
        <xs:complexContent>
            <xs:extension base="extendedType">
                <xs:sequence>
                    <xs:element name="c" type="xs:string"/>
                </xs:sequence>
                <xs:attribute name="attr" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:element name="myElem" type="superExtendedType"/>

According to schema in elemenet myElem elements a, b, c can be used. This PR fixes autocompletion to correctly offer all of them.

Please review the PR and consider pulling it to your master repo.

@ph777
Copy link
Author

ph777 commented May 30, 2018

Hello, do you plan to include this (and the following PRs #47 and #48) into your project?

If you think there is an error in the implementation or another problem, please let me know and I'll be happy to fix it. So far I think all the PRs improve your package in terms of better support for XSD constructs and I'll be pleased if you merge them in.

@pleonex
Copy link
Owner

pleonex commented Jun 1, 2018

Yes, thank you so much for the contributions!!
I just want to review the PR and test it before publishing the new version. Hopefully this weekend I will find some time. I'll let you know with the feedback (if any).

@ph777
Copy link
Author

ph777 commented Jun 1, 2018

That is great news. Thanks for it!

Let me know if help or changes needed.

@pleonex
Copy link
Owner

pleonex commented Jun 3, 2018

Thanks for the changes!
My only concern here is that we are assuming here that when we are post-processing superExtendedType, we have already post-processed extendedType so it contains the elements from baseType, right?

If I am not wrong, this may not be the case always since we are iterating a dictionary, so the order of post-processing is a bit random. But your changes are good for adding to the extension the node elements. Maybe we can address that in a different issue.

@ph777
Copy link
Author

ph777 commented Jun 4, 2018

Yes, exactly. This simple implementation of xs:extension works only for XSDs where the definition of the baseType precedes the definition of the extended type. However, it is still an improvement for well-ordered XSDs.

To handle also XSDs with xs:extension definition preceding its base type, there would have to be more then a single loop through types in post-processing. A kind of a stack with unresolved extensions would be required to keep track of types that still wait for resolution of their base type. I aggree that this can be handled as a different issue.

@pleonex
Copy link
Owner

pleonex commented Jun 4, 2018

I have some ideas for the multi round post-processing, it will be implemented from #50. Thanks!

@pleonex pleonex merged commit b0c8b30 into pleonex:master Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants