From: <tr...@do...> - 2014-11-13 21:58:17
|
<p>A new comment has been added to the following issue.</p> <table border="0"> <tr> <td width="90px" valign="top"><b>Title:</b></td> <td>RdfXmlWriter producing invalid XML under MonoTouch</td> </tr> <tr> <td><b>Project:</b></td> <td>Core Library (dotNetRDF.dll)</td> </tr> <tr> <td><b>Created By:</b></td> <td>Kal</td> </tr> <tr> <td><b>Date:</b></td> <td>2014-11-13 09:57 PM</td> </tr> <tr> <td><b>Comment:</b></td> </tr> <tr> <td colspan="2"><p> I found that commenting out the following code in RdfXmlWriter.GeneratePredicateNode() (line 633 in Libraries\core\net40\Writing\RdfXmlWriter.cs) fixes the problem:</p> <p> </p> <p> //Add Temporary Namespace to current XML Element<br /> if (prefix != null && uri != null)<br /> {<br /> context.Writer.WriteStartAttribute("xmlns", prefix, null);<br /> context.Writer.WriteRaw(Uri.EscapeUriString(WriterHelper.EncodeForXml(uri)));<br /> context.Writer.WriteEndAttribute();<br /> }</p> <p> With those lines commented out the monotouch code stops generating two xmlns declarations.</p> <p> I used the same test code to test the PCL build under .NET 4.0 as it never exhibited this problem and it still continues to produce valid XML with a single XML namespace declaration. So my guess is that the .NET implementation is clever enough to avoid repeating xml namespace declarations that have already been added to an element (or perhaps it is just cleverer at tracking the in-scope namespace declarations).</p> <p> I've spotted similar code elsewhere in the RdfXmlWriter, but these are all adding namespaces to the root rdf:RDF element. I think the difference here is that the element we are trying to add a namespace to has already had that namespace declared in the preceding call to GenerateElement() (which in turn calls StartElement).</p> <p> Rob, would you have chance to double check my working here - I haven't got everything set up to easily run all of the unit tests and so I'm not 100% happy to commit this just yet.<br /> </p></td> </tr> </table> <p> More information on this issue can be found at <a href="http://www.dotnetrdf.org/tracker/Issues/IssueDetail.aspx?id=431" target="_blank">http://www.dotnetrdf.org/tracker/Issues/IssueDetail.aspx?id=431</a></p> <p style="text-align:center;font-size:8pt;padding:5px;"> If you no longer wish to receive notifications, please visit <a href="http://www.dotnetrdf.org/tracker/Account/UserProfile.aspx" target="_blank">your profile</a> and change your notifications options. </p> |