-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
xs:choise looses some of the chooses. #42
Comments
please change choise to choice. Sorry. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Under certain conditions, some of the choices in an xs:choice do not get generated. In the enclosed example, there is on a6 field in the generated go code. This bug is subtle!!! If you remove the input for the "d" attribute from the source file, it will generate all 6 of the a elements.
Steps to reproduce the issue:
here is the input to use
=============
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="e">
xs:complexType
<xs:choice maxOccurs="unbounded">
<xs:element ref="a1"/>
<xs:element ref="a2"/>
<xs:element ref="a3"/>
<xs:element ref="a4"/>
<xs:element ref="a5"/>
<xs:element ref="a6"/>
</xs:choice>
<xs:attribute name="d" use="required">
xs:simpleType
<xs:restriction base="xs:token">
<xs:enumeration value="2"/>
<xs:enumeration value="3"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="a1">
xs:complexType
<xs:attribute name="n" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="a2">
xs:complexType
<xs:attribute name="n" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="a3">
xs:complexType
<xs:attribute name="n" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="a4">
xs:complexType
<xs:attribute name="n" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="a5">
xs:complexType
<xs:attribute name="n" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="a6">
xs:complexType
<xs:attribute name="n" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
=============
Describe the results you received:
// Code generated by xgen. DO NOT EDIT.
package test1
import (
"encoding/xml"
)
// E ...
type E struct {
XMLName xml.Name
xml:"e"
DAttr string
xml:"d,attr"
A1 []*A1
xml:"a1"
A2 []*A2
xml:"a2"
A3 []*A3
xml:"a3"
A4 []*A4
xml:"a4"
A5 []*A5
xml:"a5"
E string
xml:"e"
}
// A1 ...
type A1 struct {
XMLName xml.Name
xml:"a1"
NAttr string
xml:"n,attr"
}
// A2 ...
type A2 struct {
XMLName xml.Name
xml:"a2"
NAttr string
xml:"n,attr"
}
// A3 ...
type A3 struct {
XMLName xml.Name
xml:"a3"
NAttr string
xml:"n,attr"
}
// A4 ...
type A4 struct {
XMLName xml.Name
xml:"a4"
NAttr string
xml:"n,attr"
}
// A5 ...
type A5 struct {
XMLName xml.Name
xml:"a5"
NAttr string
xml:"n,attr"
}
// A6 ...
type A6 struct {
XMLName xml.Name
xml:"a6"
NAttr string
xml:"n,attr"
}
Describe the results you expected:
// Code generated by xgen. DO NOT EDIT.
package test1
import (
"encoding/xml"
)
// E ...
type E struct {
XMLName xml.Name
xml:"e"
DAttr string
xml:"d,attr"
A1 []*A1
xml:"a1"
A2 []*A2
xml:"a2"
A3 []*A3
xml:"a3"
A4 []*A4
xml:"a4"
A5 []*A5
xml:"a5"
A6 []*A6
xml:"a6"
E string
xml:"e"
}
// A1 ...
type A1 struct {
XMLName xml.Name
xml:"a1"
NAttr string
xml:"n,attr"
}
// A2 ...
type A2 struct {
XMLName xml.Name
xml:"a2"
NAttr string
xml:"n,attr"
}
// A3 ...
type A3 struct {
XMLName xml.Name
xml:"a3"
NAttr string
xml:"n,attr"
}
// A4 ...
type A4 struct {
XMLName xml.Name
xml:"a4"
NAttr string
xml:"n,attr"
}
// A5 ...
type A5 struct {
XMLName xml.Name
xml:"a5"
NAttr string
xml:"n,attr"
}
// A6 ...
type A6 struct {
XMLName xml.Name
xml:"a6"
NAttr string
xml:"n,attr"
}
Output of
go version
:xgen version: 0.1.0
xgen version or commit ID:
Environment details (OS, physical, etc.):
ubuntu 20.04 x86-64
The text was updated successfully, but these errors were encountered: