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

Element of complex type is duplicated #134

Open
nettnikl opened this issue Aug 23, 2024 · 1 comment
Open

Element of complex type is duplicated #134

nettnikl opened this issue Aug 23, 2024 · 1 comment

Comments

@nettnikl
Copy link

For this

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
			xmlns:ak="http://example.com/schemas" targetNamespace="http://example.com/schemas"
			elementFormDefault="qualified" attributeFormDefault="qualified"
			version="1.0">
	<xsd:element name="AAA" type="ak:BBB"/>

	<xsd:complexType name="BBB">
		<xsd:sequence>
			<xsd:element name="CCC">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string"/>
				</xsd:simpleType>
			</xsd:element>
		</xsd:sequence>
	</xsd:complexType>
</xsd:schema>

I get:

// Code generated by https://github.com/gocomply/xsd2go; DO NOT EDIT.
// Models for http://example.com/schemas
package ak

import (
	"encoding/xml"
)

// Element
type Aaa struct {
	XMLName xml.Name `xml:"AAA"`

	Ccc string `xml:",any"`
}

// XSD ComplexType declarations

type Bbb struct {
	XMLName xml.Name

	Ccc string `xml:",any"`
}

// XSD SimpleType declarations

While I expect:

// Code generated by https://github.com/gocomply/xsd2go; DO NOT EDIT.
// Models for http://example.com/schemas
package ak

import (
	"encoding/xml"
)

// Element
type Aaa Bbb

// XSD ComplexType declarations

type Bbb struct {
	XMLName xml.Name

	Ccc string `xml:",any"`
}

// XSD SimpleType declarations
@nettnikl
Copy link
Author

I think this would lead to other compilation errors, only some deduplication done somewhere internally prevents the type from coming up two times (as element and complex type).

On a side node: This however also leads to an issue, when i have a documentation string for a complexType, it is overwritten by the (potentially empty) documentation string for the element bearing the same name.

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

1 participant