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

encoding/xml: support for xml:lang attribute #14358

pdw-mb opened this issue Feb 17, 2016 · 2 comments


Copy link

commented Feb 17, 2016

xml:lang is a standard attribute defined by the XML specification. Using it is complicated by the fact that an element inherits the nearest xml:lang declaration on itself or an ancestor. For example:

    <foo xml:lang="en-GB">
      <bar>This is in en-GB</bar>

The element bar has an effective xml:lang value of "en-GB".

At the moment, an application wanting access to this information would need to consume an XML document token by token, and maintain its own stack of xml:lang attributes (or include an xml:lang attribute on all parent structs being unmarshalled, and process those). It would be nice if Decoder maintained this stack itself, and exposed it to structs being unmarshaled so that you could easily get the current effective xml:lang attribute.

There is code to do the above here:

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Feb 17, 2016

@ianlancetaylor ianlancetaylor changed the title encoding/xml - support for xml:lang attribute encoding/xml: support for xml:lang attribute Feb 17, 2016


This comment has been minimized.

Copy link

commented Apr 30, 2018

Just naming the field xml:lang works for marshaling but not for unmarshaling currently:


This comment has been minimized.

Copy link

commented Apr 30, 2018

Ah, giving it the implicitly-defined namespace URL works completely:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.