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

Unmarshal error with namespaced and non-namespaced XML Attributes #15

Open
klauern opened this issue Feb 17, 2017 · 5 comments
Open

Unmarshal error with namespaced and non-namespaced XML Attributes #15

klauern opened this issue Feb 17, 2017 · 5 comments
Assignees

Comments

@klauern
Copy link

klauern commented Feb 17, 2017

You're probably loving all of these issues...Sorry about that.

I found something that I'm not sure if it's a Go encoding/xml error, or if there's something wrong with my XML. The following piece of XML

<ser:binding type="SOAP" isSoap12="false" xsi:type="con:SoapBindingType" xmlns:con="http://www.bea.com/wli/sb/services/bindings/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- other nested items -->
...
</ser:binding>

Generates the following struct:

type Chiser_binding struct {
	Attr_con             string                `xml:"xmlns con,attr"  json:",omitempty"`
	Attr_isSoap12        string                `xml:"isSoap12,attr"  json:",omitempty"`
	Attr_type            string                `xml:" type,attr"  json:",omitempty"`
	Attr_xsi_type        string                `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"  json:",omitempty"`
	Attr_xsi             string                `xml:"xmlns xsi,attr"  json:",omitempty"`
	Chicon_WSI_compliant *Chicon_WSI_compliant `xml:"http://www.bea.com/wli/sb/services/bindings/config WSI-compliant,omitempty" json:"WSI-compliant,omitempty"`
	Chicon_port          *Chicon_port          `xml:"http://www.bea.com/wli/sb/services/bindings/config port,omitempty" json:"port,omitempty"`
	Chicon_selector      *Chicon_selector      `xml:"http://www.bea.com/wli/sb/services/bindings/config selector,omitempty" json:"selector,omitempty"`
	Chicon_wsdl          *Chicon_wsdl          `xml:"http://www.bea.com/wli/sb/services/bindings/config wsdl,omitempty" json:"wsdl,omitempty"`
	XMLName              xml.Name              `xml:"http://www.bea.com/wli/sb/services binding,omitempty" json:"binding,omitempty"`
}

However, when I unmarshal, I get the following error:

proxy_test.go:18: lint.Chiser_binding field "Attr_type" with tag " type,attr" conflicts with field "Attr_xsi_type" with tag "http://www.w3.org/2001/XMLSchema-instance type,attr"
@klauern
Copy link
Author

klauern commented Feb 17, 2017

@klauern
Copy link
Author

klauern commented Feb 17, 2017

Okay, I think this is a Go issue: golang/go#13400 . There appear to be many issues with namespaces in there, and in particular, golang/go#8535 that points to this one.

@gnewton
Copy link
Owner

gnewton commented Feb 17, 2017

Yes, there are issues in go/xml's ability to handle namespaces. I have commented either in one of those many issues or in the golang list (quite a while ago, like a year). I will add this external limitation to the chidley 'Limitations' section.

They really are showstoppers for anyone who wants to do serious XML.... :-(

@gnewton gnewton self-assigned this Feb 17, 2017
@gnewton
Copy link
Owner

gnewton commented Feb 17, 2017

I am going to change this issue to "Document limitations of chidley due to limitations (bugs) in underlying go/xml marshalling/demarshalling".

@gnewton
Copy link
Owner

gnewton commented Feb 17, 2017

Note in golang/go#13400 indicates Milestone Go1.9Early, Go1.8, but it clearly did no make in into 1.8, as per release notes https://beta.golang.org/doc/go1.8 the only changes to go/xml:

encoding/xml

    Unmarshal now has wildcard support for collecting all attributes using the new ",any,attr" struct tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants