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

String-derived element is marked as optional when minLength > 0 #19

Open
antonielly opened this issue Oct 29, 2015 · 1 comment
Open
Labels

Comments

@antonielly
Copy link

The generator available at
https://xsd-forms.herokuapp.com/
appears to look at the "pattern" but ignore "minLength" or "length" in order to decide marking a string field as mandatory (*) or optional ().

Minimal working examples:

a) The defect appears

<?xml version="1.0" encoding="utf-8" ?>
<schema xmlns:this="http://example.com/"
    targetNamespace="http://example.com/"
    xmlns="http://www.w3.org/2001/XMLSchema">

    <simpleType name="NonEmptyString">
        <restriction base="string">
            <minLength value="1"/>
        </restriction>
    </simpleType>

    <element name="nonEmptyString" type="this:NonEmptyString"/>
</schema>

b) The defect appears

<?xml version="1.0" encoding="utf-8" ?>
<schema xmlns:this="http://example.com/"
    targetNamespace="http://example.com/"
    xmlns="http://www.w3.org/2001/XMLSchema">

    <simpleType name="NonEmptyString">
        <restriction base="string">
            <pattern value="[0-9A-Z]*"/>
            <minLength value="1"/>
        </restriction>
    </simpleType>

    <element name="nonEmptyString" type="this:NonEmptyString"/>
</schema>

c) The defect does not appear (i.e. it works correctly, as it should)

<?xml version="1.0" encoding="utf-8" ?>
<schema xmlns:this="http://example.com/"
    targetNamespace="http://example.com/"
    xmlns="http://www.w3.org/2001/XMLSchema">

    <simpleType name="NonEmptyString">
        <restriction base="string">
            <pattern value="[0-9A-Z]+"/>
        </restriction>
    </simpleType>

    <element name="nonEmptyString" type="this:NonEmptyString"/>
</schema>

d) The defect appears

<?xml version="1.0" encoding="utf-8" ?>
<schema xmlns:this="http://example.com/"
    targetNamespace="http://example.com/"
    xmlns="http://www.w3.org/2001/XMLSchema">

    <simpleType name="SingleCharacter">
        <restriction base="string">
            <length value="1"/>
        </restriction>
    </simpleType>

    <element name="singleCharacter" type="this:SingleCharacter"/>
</schema>
@davidmoten
Copy link
Owner

Thanks for the reports. Excuse my tardiness as this hasn't been an active project for me for a while. I'll have a look though and see if there's a quickish fix on this.

@davidmoten davidmoten added the bug label Nov 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants