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

xsdgen: gen type "measResults": Unknown built-in type "anySimpleType" #112

Closed
shmsr opened this issue Jul 2, 2020 · 6 comments
Closed

Comments

@shmsr
Copy link
Contributor

shmsr commented Jul 2, 2020

xsdgen throws an error while operating on an XSD file:

gen type "measResults": Unknown built-in type "anySimpleType"

Refer: https://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec (32435-c00.zip)
The zipped file contains a doc which includes the XSD as well: 32435-c00.zip

I'm attaching the XSD file here itself fetched from the above referenced link:

<?xml version="1.0" encoding="UTF-8"?>

<!--
  3GPP TS 32.435 Performance Measurement XML file format definition
  data file XML schema
  measCollec.xsd
-->

<schema targetNamespace="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:mc="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec">

    <!-- Measurement collection data file root XML element -->

    <element name="measCollecFile">
        <complexType>
            <sequence>
                <element name="fileHeader">
                    <complexType>
                        <sequence>
                            <element name="fileSender">
                                <complexType>
                                    <attribute name="localDn" type="string" use="optional" />
                                    <attribute name="elementType" type="string" use="optional" />
                                </complexType>
                            </element>
                            <element name="measCollec">
                                <complexType>
                                    <attribute name="beginTime" type="dateTime" use="required" />
                                </complexType>
                            </element>
                        </sequence>
                        <attribute name="fileFormatVersion" type="string" use="required" />
                        <attribute name="vendorName" type="string" use="optional" />
                        <attribute name="dnPrefix" type="string" use="optional" />
                    </complexType>
                </element>
                <element name="measData" minOccurs="0" maxOccurs="unbounded">
                    <complexType>
                        <sequence>
                            <element name="managedElement">
                                <complexType>
                                    <attribute name="localDn" type="string" use="optional" />
                                    <attribute name="userLabel" type="string" use="optional" />
                                    <attribute name="swVersion" type="string" use="optional" />
                                </complexType>
                            </element>
                            <element name="measInfo" minOccurs="0" maxOccurs="unbounded">
                                <complexType>
                                    <sequence>
                                        <element name="job" minOccurs="0">
                                            <complexType>
                                                <attribute name="jobId" type="string" use="required" />
                                            </complexType>
                                        </element>
                                        <element name="granPeriod">
                                            <complexType>
                                                <attribute name="duration" type="duration" use="required" />
                                                <attribute name="endTime" type="dateTime" use="required" />
                                            </complexType>
                                        </element>
                                        <element name="repPeriod" minOccurs="0">
                                            <complexType>
                                                <attribute name="duration" type="duration" use="required" />
                                            </complexType>
                                        </element>
                                        <choice>
                                            <element name="measTypes">
                                                <simpleType>
                                                    <list itemType="Name" />
                                                </simpleType>
                                            </element>
                                            <element name="measType" minOccurs="0" maxOccurs="unbounded">
                                                <complexType>
                                                    <simpleContent>
                                                        <extension base="Name">
                                                            <attribute name="p" type="positiveInteger" use="required" />
                                                        </extension>
                                                    </simpleContent>
                                                </complexType>
                                            </element>
                                        </choice>
                                        <element name="measValue" minOccurs="0" maxOccurs="unbounded">
                                            <complexType>
                                                <sequence>
                                                    <choice>
                                                        <element name="measResults">
                                                            <simpleType>
                                                                <list itemType="mc:measResultType" />
                                                            </simpleType>
                                                        </element>
                                                        <element name="r" minOccurs="0" maxOccurs="unbounded">
                                                            <complexType>
                                                                <simpleContent>
                                                                    <extension base="mc:measResultType">
                                                                        <attribute name="p" type="positiveInteger" use="required" />
                                                                    </extension>
                                                                </simpleContent>
                                                            </complexType>
                                                        </element>
                                                    </choice>
                                                    <element name="suspect" type="boolean" minOccurs="0" />
                                                </sequence>
                                                <attribute name="measObjLdn" type="string" use="required" />
                                            </complexType>
                                        </element>
                                    </sequence>
                                    <attribute name="measInfoId" type="string" use="optional" />
                                </complexType>
                            </element>
                        </sequence>
                    </complexType>
                </element>
                <element name="fileFooter">
                    <complexType>
                        <sequence>
                            <element name="measCollec">
                                <complexType>
                                    <attribute name="endTime" type="dateTime" use="required" />
                                </complexType>
                            </element>
                        </sequence>
                    </complexType>
                </element>
            </sequence>
        </complexType>
    </element>

    <simpleType name="measResultType">
        <union memberTypes="float">
            <simpleType>
                <restriction base="string">
                    <enumeration value="NIL" />
                </restriction>
            </simpleType>
        </union>
    </simpleType>

</schema>

From the documentation, I feel that it should work but it's not. How can I debug this?

@shmsr shmsr changed the title gen type "measResults": Unknown built-in type "anySimpleType" xsdgen: gen type "measResults": Unknown built-in type "anySimpleType" Jul 2, 2020
@shmsr
Copy link
Contributor Author

shmsr commented Jul 3, 2020

@droyo did you find some time to look into this?

@droyo
Copy link
Owner

droyo commented Jul 3, 2020

The error you're getting is because there is no entry for xsd.AnySimpleType in builtinTbl. You should be able to add an entry and give it the string type.

Looking at the schema, measResults should be a list of measResultType, which itself can either be a float or the string "NIL". xsdgen does not have good support for union types today, so it would just become a string, and then measResults should be a []string in the generated output.

@shmsr
Copy link
Contributor Author

shmsr commented Jul 3, 2020

Yes, I made the changes in go-xml/xsdgen/builtin.go and go-xml/xsdgen/xsdgen.go and it works. Thanks for your suggestions.

I'm still thinking of ways where I can do it in a better way. If you have some more suggestions, I'd love to hear them.

@droyo
Copy link
Owner

droyo commented Jul 3, 2020

Sure, if you want to file a PR or point me to your fork I can take a look sometime.

@shmsr
Copy link
Contributor Author

shmsr commented Jul 8, 2020

Sorry, @droyo that I took a long time to reply back to you. Please refer the commit for the changes.

You can then close this issue. Thanks!

@droyo
Copy link
Owner

droyo commented Jul 13, 2020

Thanks @shmsr . Looking at your commit, it's very specific to the schema you're using and wouldn't be generically usable. I think the best fit for a generic anySimpleType would be a string rather than a float64. And then sum types like union and enum would have to be implemented on top of that.

I'm glad you figured it out, though!

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