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

Compound fields don't have min/max occurs #748

Closed
tefra opened this issue Feb 21, 2023 · 4 comments
Closed

Compound fields don't have min/max occurs #748

tefra opened this issue Feb 21, 2023 · 4 comments

Comments

@tefra
Copy link
Owner

tefra commented Feb 21, 2023

          It seems that most restrictions are in the dataclass, but minOccurs and maxOccurs are not. See the example:
    <xs:simpleType name="astroPyPath">
        <xs:restriction base="xs:string">
            <xs:pattern value="hdul(\[.+\]).(data|header)(\[([\w-]+|[:\d,]+)\])+"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="someNumber">
        <xs:restriction base="xs:float">
            <xs:minExclusive value="10"/>
            <xs:maxInclusive value="100"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="functions">
        <xs:choice>
            <xs:element name="Statistics" type="xs:string" minOccurs="4" maxOccurs="12"/>
            <xs:element name="Transforms" type="someNumber"/>
            <xs:element name="Mathematics" type="mathematicFunctions"/>
            <xs:element name="ReadFits" type="astroPyPath" minOccurs="1" maxOccurs="unbounded"/>
        </xs:choice>
    </xs:complexType>

becomes:

@dataclass
class Functions:
    class Meta:
        name = "functions"

    choice: List[object] = field(
        default_factory=list,
        metadata={
            "type": "Elements",
            "choices": (
                {
                    "name": "Statistics",
                    "type": str,
                    "namespace": "",
                },
                {
                    "name": "Transforms",
                    "type": float,
                    "namespace": "",
                    "min_exclusive": 10.0,
                    "max_inclusive": 100.0,
                },
                {
                    "name": "Mathematics",
                    "type": MathematicFunctions,
                    "namespace": "",
                },
                {
                    "name": "ReadFits",
                    "type": str,
                    "namespace": "",
                    "pattern": r"hdul(\[.+\]).(data|header)(\[([\w-]+|[:\d,]+)\])+",
                },
            ),
        }
    )

Originally posted by @martinwiesmann in #737 (comment)

@tefra tefra changed the title Compound fields don't have min/mac occurs Compound fields don't have min/max occurs Feb 21, 2023
@tefra
Copy link
Owner Author

tefra commented May 28, 2023

I am closing this one, for now it's not super important

@tefra tefra closed this as completed May 28, 2023
@martinwiesmann
Copy link

Maybe not super important, but would be useful to have it fixed.
Would you mind reopening this issue, so that it doesn't get forgotten?

@tefra tefra reopened this Aug 24, 2023
@martinwiesmann
Copy link

Thanks. And thank you for your great work.

@tefra
Copy link
Owner Author

tefra commented Mar 23, 2024

This is now merged #994

@tefra tefra closed this as completed Mar 23, 2024
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