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

Insert only required elements adds optional elements #993

Open
GniLudio opened this issue May 12, 2024 · 3 comments
Open

Insert only required elements adds optional elements #993

GniLudio opened this issue May 12, 2024 · 3 comments

Comments

@GniLudio
Copy link

I have the following xsd with these types: Timestamp, EpisodeID, EpisodeTime, EpisodeType.
But Insert only required elements adds episodeType altough that element is optional.

XSD (test.xsd)

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="testing" xmlns="testing" elementFormDefault="qualified">
    <!-- Just setting root to a timestamp -->
    <xs:element name="root" type="Timestamp" />

    <!-- Timestamp: EpisodeID + EpisodeTime -->
    <xs:complexType name="Timestamp">
        <xs:complexContent>
            <xs:extension base="EpisodeID">
                <xs:sequence>
                    <xs:element name="episodeTime" type="EpisodeTime" />
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <!-- EpisodeID: EpisodeNumber + EpisodeType (optional) -->
    <xs:complexType name="EpisodeID">
        <xs:sequence>
            <xs:element name="episode" type="xs:decimal"></xs:element>
            <xs:element name="episodeType" type="EpisodeType" minOccurs="0" />
        </xs:sequence>
    </xs:complexType>

    <!-- EpisodeTime: eg. 00:00:00 or 05:33 -->
    <xs:simpleType name="EpisodeTime">
        <xs:restriction base="xs:string">
            <xs:pattern value="([0-9]?[0-9]:)?([0-9]?[0-9]:)?([0-9]?[0-9])" />
        </xs:restriction>
    </xs:simpleType>

    <!-- EpisodeType: full | trailer | bonus -->
    <xs:simpleType name="EpisodeType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="full" />
            <xs:enumeration value="trailer" />
            <xs:enumeration value="bonus" />
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

XML (test.xml)

Before inserting required elements:

<?xml version="1.0" encoding="UTF-8"?>
<root
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="testing" 
    xsi:schemaLocation="testing test.xsd">
</root>

After inserting required elements:

<?xml version="1.0" encoding="UTF-8"?>
<root
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="testing" 
    xsi:schemaLocation="testing test.xsd">
    <episode></episode>
    <episodeType>full</episodeType>
    <episodeTime></episodeTime>
</root>
@angelozerr
Copy link
Contributor

Thanks for having reported the issue.

I think it is a usecase we dont cover. Need some times to investigate the problem.

@GniLudio
Copy link
Author

I think it is caused by extending multiple times.
(the bug doesn't occur when inlining everything in Timestamp)

@angelozerr
Copy link
Contributor

Ok thanks for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants