Bug 3972 - XElement's ToString shows incorrect namespace
Summary: XElement's ToString shows incorrect namespace
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: 2.10.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-03-19 13:26 UTC by Chris Hardy [MSFT]
Modified: 2012-05-14 05:32 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Chris Hardy [MSFT] 2012-03-19 13:26:52 UTC
Created attachment 1541 [details]
Test case

There seems to be an error in the way XElement does ToString().
Attached is a minimal test program which shows the problem. The first test gives correct output. The xml has one default namespace. The second gives wrong output. The difference is that the second has two namespaces with no default.

The second test:

Input xml:
<xsi:Event xsi1:type="xsi:SubscriptionEvent" xmlns:xsi="http://relevo.se/xsi" xmlns:xsi1="http://www.w3.org/2001/XMLSchema-instance">;
<xsi:eventData xsi1:type="xsi:CallSubscriptionEvent"/>
</xsi:Event>

The code extracts the first subelement . ToString() of the first subelement gives:

<eventData d1p1:type="xsi:CallSubscriptionEvent" xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://relevo.se/xsi" />

The d1p1:type attribute should be CallSubscriptionEvent and not xsi:CallSubscriptionEvent since it's the default namespace.
Comment 2 Atsushi Eno 2012-05-14 05:32:51 UTC
Fixed in master and mono-2-10.