I need to produce the following xml :
<AccessControlList>
<Grant>
<Grantee
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
<ID>xxxx-xx</ID>
<DisplayName>rahul.khan</DisplayName>
</Grantee>
<Permission>FULL_CONTROL</Permission>
</Grant>
</AccessControlList>
My struct is defined like this :
type Grantee struct {
Xmlns_xsi string `xml:"xmlns xsi,attr,omitempty"`
Xsi_type string `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr,omitempty"`
ID string `xml:",omitempty"`
DisplayName string `xml:",omitempty"`
}
However when i marshall this structure the resulting xml document that is produced looks like this :
<AccessControlList>
<Grant>
<Grantee
xmlns:XMLSchema-instance="http://www.w3.org/2001/XMLSchema-instance" XMLSchema-instance:type="CanonicalUser">
<ID>xxxx-xx</ID>
<DisplayName>rahul.khan</DisplayName>
</Grantee>
<Permission>FULL_CONTROL</Permission>
</Grant>
</AccessControlList>
As a result, when the doc is unmarshalled, the type field doesn't seem to be parsed by the aws-go-sdk.
For e.g this is the unmarhsalled output that i need to get
Grantee: {
DisplayName: "rahul.khan",
ID: "xxxx-xx",
Type: "CanonicalUser"
},
Permission: "FULL_CONTROL"
}
Instead what I get is this :
Grantee: {
DisplayName: "rahul.khan",
ID: "xxxx-xx"
},
Permission: "FULL_CONTROL"
}
The Type attribute seems to be missing from the unmarshalled output. The only difference that I see in the xml document produced by my code and from aws is this line
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"
v/s
xmlns:XMLSchema-instance="http://www.w3.org/2001/XMLSchema-instance" XMLSchema-instance:type="CanonicalUser"
Appreciate if someone can help me understand how to fix this issue ?