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

Elements are being pushed twice #90

Open
GiovanePS opened this issue Mar 10, 2025 · 0 comments
Open

Elements are being pushed twice #90

GiovanePS opened this issue Mar 10, 2025 · 0 comments

Comments

@GiovanePS
Copy link

GiovanePS commented Mar 10, 2025

Description
If an <element> is outside a <complexType> element, it is pushed twice. Like the following example:

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

	<xsd:element name="SomeElement">
	</xsd:element>
	<xsd:simpleType name="SomeSimpleType">
		<xsd:restriction base="xsd:string" />
	</xsd:simpleType>
</xsd:schema>

Just look at the code of OnElement method to see that this is true.

Steps to reproduce the issue:

  1. Copy the above XSD to a blank file (minimal.xsd)
  2. Run xgen -l Go -i minimal.xsd

Describe the results you received:
With the xgen version at commit d0691b7, there is no difference in the output, but the problem is still there. It is just perceived after, for example, the changes made in #87 and #89. With those changes, this will be the output received:

// Code generated by xgen. DO NOT EDIT.

package schema

// SomeElement ...
type SomeElement string

// SomeSimpleType ...
type SomeSimpleType interface{}

Describe the results you expected:
And then, this will be the expected output:

// Code generated by xgen. DO NOT EDIT.

package schema

// SomeElement ...
type SomeElement *SomeElement

// SomeSimpleType ...
type SomeSimpleType string

Output of go version:

go version go1.24.0 linux/amd64

xgen version or commit ID:

xgen version: 0.1.0
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