(I confirmed my XSD is valid and would produce the desired XML structure by copying it into http://xsd2xml.com/)
But the Go struct generated by xgen looks as follows:
// Copyright 2020 The xgen Authors. All rights reserved.
//
// DO NOT EDIT: generated by xgen XSD generator
//
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package schema
import (
"encoding/xml"
)
// Attribute ...
type Attribute struct {
XMLName xml.Name `xml:"attribute"`
OriginAttr string `xml:"origin,attr"`
}
There is no field where I can put the 'value' (Destination-Host) of the attribute tag.
Is my XSD invalid, can I edit it to have the expected 'value' field, or is this an issue in the generator? I'm expecting a struct like:
type Attribute struct {
XMLName xml.Name `xml:"attribute"`
OriginAttr string `xml:"origin,attr"`
Value string `xml:",chardata"`
}
Is there also a way to mark a struct field as xml:",cdata" ? Or will this involve editing the generated code?
Description
I have a (simplified) XSD as follows (partial but functional example):
The XML that goes with it would look like this:
(I confirmed my XSD is valid and would produce the desired XML structure by copying it into http://xsd2xml.com/)
But the Go struct generated by xgen looks as follows:
There is no field where I can put the 'value' (
Destination-Host
) of theattribute
tag.Is my XSD invalid, can I edit it to have the expected 'value' field, or is this an issue in the generator? I'm expecting a struct like:
Is there also a way to mark a struct field as
xml:",cdata"
? Or will this involve editing the generated code?