XML in: different XML out

198 views
Skip to first unread message

Glen Newton

unread,
Aug 8, 2014, 11:27:00 AM8/8/14
to golan...@googlegroups.com
In a simple example of XML, the encoder generates XML that is different from the input XML.

Here is the example:
 http://play.golang.org/p/BqSJy6IgUq

If you take the input XML RDF verification using the W3C RDF validator (http://www.w3.org/RDF/Validator/), you get:

Your RDF document validated successfully.

If you take the output XML generated by the above example, you get some errors:
Error: {W109} The namespace URI: <xmlns> is relative. Such use has been deprecated by the W3C, and may result in RDF interoperability failures. Use an absolute namespace URI.[Line = 1, Column = 176]
Error: {E201} Illegal attributes on rdf:RDF[Line = 1, Column = 176]


The problem is that the output XML is not equivalent to the the input XML:
Input XML first 2 elements:
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
    rdf:about="http://www.recshop.fake/cd/Empire Burlesque">


Output XML first 2 elements:
<RDF
    xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:_xmlns="xmlns"
    xmlns:cd="http://www.recshop.fake/cd#"
    _xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <Description
      xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:_="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      _:about="http://www.recshop.fake/cd/Empire Burlesque">


Different formatting (which is OK) aside, this is different XML. The 'xmlns:_xmlns="xmlns"' is a weird artifact and is not correct.

Am I doing something incorrect in how I have defined the example's structs to cause this problem? Any suggestions welcome.

egon

unread,
Aug 8, 2014, 1:21:37 PM8/8/14
to golan...@googlegroups.com
It looks like a bug. Also there are other issues with xml namespaces https://code.google.com/p/go/issues/list?can=2&q=xml+namespace

But I didn't notice this case in those issues. It seems the namespaces only work for attributes. So you should probably create an issue.

+ egon 

Glen Newton

unread,
Aug 10, 2014, 10:13:59 AM8/10/14
to golan...@googlegroups.com
I was afraid you were going to say that!  :-)

I will submit an issue in the next day or so.

Thanks!
-Glen
Reply all
Reply to author
Forward
0 new messages