Description
If a complexType is defined with mixed="true", it should collect the innerXml or CDATA in addition to the tags. The examples in this ticket are generated using the SFCC catalog.xsd which also requires the xml.xsd file from https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/xsd/.
Inside of it, the following types are declared:
<xsd:complexType name="sharedType.CustomAttributes" mixed="false">
<xsd:sequence>
<xsd:element name="custom-attribute" type="sharedType.CustomAttribute" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="sharedType.CustomAttribute" mixed="true">
<xsd:sequence>
<xsd:element name="value" type="simpleType.Generic.String" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="attribute-id" type="simpleType.Generic.NonEmptyString.256" use="required" />
<xsd:attribute ref="xml:lang" />
</xsd:complexType>
This generates the following Go code:
// SharedTypeCustomAttributes ...
type SharedTypeCustomAttributes struct {
XMLName xml.Name `xml:"sharedType.CustomAttributes"`
Customattribute []*SharedTypeCustomAttribute `xml:"custom-attribute"`
}
// SharedTypeCustomAttribute ...
type SharedTypeCustomAttribute struct {
XMLName xml.Name `xml:"sharedType.CustomAttribute"`
AttributeidAttr string `xml:"attribute-id,attr"`
XmlLangAttr string `xml:"xml:lang,attr,omitempty"`
Value []string `xml:"value"`
}
In most cases from SFCC files, this is presented as <custom-attribute attribute-id="foo">bar</custom-attribute>, and using xgen there's no way to get access to the bare contents of the optional <value/> tag.
Steps to reproduce the issue:
- Use the XSD files mentioned above.
- Run
xgen -i catalog.xsd -l Go -o tmp/catalog
Describe the results you received:
Note that there's no way of getting the inner XML, only Value[].
Describe the results you expected:
A way to get the inner XML in addition to Value[].
Output of go version:
go version go1.22.3 darwin/arm64
xgen version or commit ID:
Environment details (OS, physical, etc.):
macOS 14.5
Description
If a
complexTypeis defined withmixed="true", it should collect theinnerXmlor CDATA in addition to the tags. The examples in this ticket are generated using the SFCCcatalog.xsdwhich also requires thexml.xsdfile from https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/xsd/.Inside of it, the following types are declared:
This generates the following Go code:
In most cases from SFCC files, this is presented as
<custom-attribute attribute-id="foo">bar</custom-attribute>, and using xgen there's no way to get access to the bare contents of the optional<value/>tag.Steps to reproduce the issue:
xgen -i catalog.xsd -l Go -o tmp/catalogDescribe the results you received:
Note that there's no way of getting the inner XML, only
Value[].Describe the results you expected:
A way to get the inner XML in addition to
Value[].Output of
go version:xgen version or commit ID:
Environment details (OS, physical, etc.):
macOS 14.5