-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
encoding/xml: support QName values / expose namespace bindings #12406
Comments
This could help with an issue I reported at hooklift/gowsdl#37 In that case, the Having access to the namespaces from the outer |
Thanks for the note. I think we may try one more time to get namespaces right in xml. And then we're going to give up and say "what we've got is what we've got." |
Thanks @rsc. In the |
Thanks @rsc. I think what's there is pretty close. QName values in XML documents are inherently problematic because you need access to the current namespace bindings in order to understand them, but they are fairly widely used. After filing this issue, I've realised that the fix for attributes is more problematic as UnmarshallXMLAttr doesn't currently get passed the Decoder object, so addressing this would require a breaking change to the API, rather than just the addition of a method. |
Blocked on #13400. |
I've implemented the proposed change in a fork that can be found here: https://code.blinkace.com/go/xml The relevant changes are:
I've also implemented a QName package which is a Marshaler / Unmarshaler. This might be better merged with XMLName. |
It's not uncommon for XML to contain QNames as element and attribute values, e.g.
In order to correctly unmarshal the value, you need to know the namespace bindings in effect for my-element, but Decoder doesn't appear to expose this information. A simple addition to encoding/xml of:
allows unmarshallers to access the necessary information, for example, I can now write:
Arguably, something like the above, and a corresponding attribute unmarshaller could be provided on the standard xml.Name.
More discussion of this issue here:
https://groups.google.com/forum/#!searchin/golang-nuts/QName/golang-nuts/DexmVLQOJxk/whBaKK9ntHsJ
go version go1.5 darwin/amd64
The text was updated successfully, but these errors were encountered: