Skip to content

Support for xsd:restriction with empty base #158

@aplr

Description

@aplr

I'm getting the following error when trying to generate code from the referenced XSD files:

panic: Not implemented: xsd:extension/@base empty, cannot extend unknown type

The error is misleading, it should be "xsd:restriction/@base empty ...", I guess it was just copied from xsd:extension, that's one problem.

Below is the part of the XSD where the generator panics. I see this construct is overly complex and in go code it should realistically just be a simple float64 in this case. However, it would be good to have the generator not panic but rather skip / generate a simple type from that.

    <xsd:simpleType name="p7">
        <xsd:restriction> // Here's the empty restriction
            <xsd:simpleType>
                <xsd:union>
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:decimal">
                            <xsd:totalDigits value="12" />
                            <xsd:fractionDigits value="2" />
                            <xsd:minInclusive value="0.01" />
                            <xsd:maxInclusive value="9999999999.99" />
                            <xsd:pattern value="[\+\-]?([1-9]\d{0,9}|0)(\.\d{2})" />
                        </xsd:restriction>
                    </xsd:simpleType>
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:decimal">
                            <xsd:totalDigits value="12" />
                            <xsd:fractionDigits value="2" />
                            <xsd:minInclusive value="-9999999999.99" />
                            <xsd:maxInclusive value="-0.01" />
                            <xsd:pattern value="[\+\-]?([1-9]\d{0,9}|0)(\.\d{2})" />
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:union>
            </xsd:simpleType>
        </xsd:restriction>
    </xsd:simpleType>

The XSDs can be downloaded from here:
https://developer.datev.de/en/file-format/details/datev-xml-interface-online/xsdminusfiles. The failing restriction is in Belegverwaltung_online_ledger_types_v060.xsd

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions