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

Go Generator - Main type generates incorrect xml: tag #46

Open
jimidle opened this issue Mar 22, 2022 · 1 comment
Open

Go Generator - Main type generates incorrect xml: tag #46

jimidle opened this issue Mar 22, 2022 · 1 comment

Comments

@jimidle
Copy link

jimidle commented Mar 22, 2022

Description

The xml tag for the top type is generated incorrectly, which makes i impossible to unmarshall in to the top structure.

Steps to reproduce the issue:

  1. Start with the svg xsd definition and generate a struct for it
  2. Try to unmarshal an svg string in to an instance
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="500pt" height="300pt" viewBox="0 0 500 300" version="1.1">
    <defs>
        <clipPath id="clip1">
            <path d="M 51 203 L 135 203 L 135 269.839844 L 51 269.839844 Z M 51 203 "/>
        </clipPath>
        <clipPath id="clip2">
            <path d="M 167 190 L 251 190 L 251 269.839844 L 167 269.839844 Z M 167 190 "/>
        </clipPath>
        <clipPath id="clip3">
            <path d="M 282 177 L 366 177 L 366 269.839844 L 282 269.839844 Z M 282 177 "/>
        </clipPath>
        <clipPath id="clip4">
            <path d="M 397 32 L 481 32 L 481 269.839844 L 397 269.839844 Z M 397 32 "/>
        </clipPath>
    </defs>
    <g id="surface1521">
...
  1. You will receive an error: expected element type <svgType> but have <svg>

Describe the results you received:

Unable to parse an svg XML file because the generated tag for xml appends Type to the XML tag:

// SvgType ...
type SvgType struct {
	XMLName                       xml.Name `xml:"svgType"`

It does this for all XMLName declarations. Then will declare:

type Svg *SvgType

Which also will then sometimes generate duplicates because it does not distinguish between things like simpletype and complextype. For instance with SVG you will see:

type Title string
type Title *TitleType

Describe the results you expected:

An unmarshalled svg struct, with the generated tag being xml:"svg"

Output of go version:

go version go1.18 darwin/amd64

xgen version or commit ID:

xgen version: 0.1.0

Environment details (OS, physical, etc.):
OSX version 12.3

@jimidle
Copy link
Author

jimidle commented Mar 22, 2022

[](url
xgen.zip
)

xsd files for generating and .swg file for unmarshalling attached. They will reproduce the issue described above.

@jimidle jimidle changed the title Main type generates incorrect xml: tag Go Generator - Main type generates incorrect xml: tag Mar 22, 2022
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