Jim--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
no, as best as I can tell, the namespace of the root element is always set as the default namespace. As Jim mentioned though, if you (or someone else) are relying on specific namespace prefix values, that code is broken.
--
only way I can find to do it is to actually remove the namespace declaration on your C type (http://play.golang.org/p/PRQcMtviEQ). Then <c> will be declared as being in the default namespace, which works in this single case, but would create problems if the default namespace changes. So no, I don't think there is a way to have encoding/xml automatically remove redundant namespace declarations.
I'm actually trying to remove the implicit namespace on child elements of an element that has a namespace. That is to say in this example:<a xmlns="b"><c></c></a>The namespace of the 'c' element is also 'b'. There's no way to remove this default namespace using xml.Marshal.Have I got this right?
Perhaps you could construct an example with xml.Marshal that outputs either of the 2 forms I gave? My issue is that I cannot work out how to do either of them.
I thought you were trying to get it to output "<a xmlns="b"><c></c></a>". Perhaps I misunderstood?
In any event, for XML attributes, a global map of prefixes is maintained, and is consulted so that for a given namespace URI, it is only ever mapped to a prefix once, and that prefix is used throughout the document. For XML elements, if your Go code declares an explicit namespace, then that is always set as the default namespace on the element in the XML output.
Perhaps you could construct an example with xml.Marshal that outputs either of the 2 forms I gave? My issue is that I cannot work out how to do either of them.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/tGX1xp-nBm4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.