Hello, When System.ServiceModel.Syndication.Atom10ItemFormatter.ReadXml() finds a <source> tag, it hands if off to ReadSourceFeed() which hands if off to Atom10FeedFormatter.ReadFrom() which tries to load the inner elements as though it were the contents of a normal feed.
This doesn't work, however, because Atom10FeedFormatter checks for a <feed> tag (which it doesn't find) and throws an exception complaining that "title" isn't a valid element (which took me a while to decipher). The attached patch walks through the child elements of <source> and adds this information to a generic SyndicationFeed(). (The ChangeLog diff shows another commit from me. If that's a problem, I can re-diff without it) Should I open a bug report for this? Thanks, cmn -- Carlos Martín Nieto | http://www.cmartin.tk "¿Cómo voy a decir bobadas si soy mudo?" -- CACHAI
commit dd345048b93b7c7db44f85c15394cf0476fbd545 Author: Carlos Martín Nieto <car...@cmartin.tk> Date: Wed Jun 9 13:20:00 2010 +0200 2010-06-09 Carlos Martín Nieto <car...@cmartin.tk> * Atom10ItemFormatter.cs: Correctly handle <source> tags We can't use Atom10FeedFormatter to read the contents of a <source> element because it expects a <feed> tag. Instead, walk through the fields and add them to our local SyndicationFeed that gets returned diff --git a/class/System.ServiceModel.Web/System.ServiceModel.Syndication/Atom10ItemFormatter.cs b/class/System.ServiceModel.Web/System.ServiceModel.Syndication/Atom10ItemFormatter.cs index a845ae2..4d590e4 100644 --- a/class/System.ServiceModel.Web/System.ServiceModel.Syndication/Atom10ItemFormatter.cs +++ b/class/System.ServiceModel.Web/System.ServiceModel.Syndication/Atom10ItemFormatter.cs @@ -380,13 +380,35 @@ namespace System.ServiceModel.Syndication { SyndicationFeed feed = null; if (!reader.IsEmptyElement) { + feed = new SyndicationFeed(); reader.Read (); - Atom10FeedFormatter ff = new Atom10FeedFormatter (); - ff.ReadFrom (reader); - feed = ff.Feed; + for (reader.MoveToContent (); reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) { + if (reader.NodeType == XmlNodeType.Element && reader.NamespaceURI == AtomNamespace) { + switch (reader.LocalName) { + case "title": + feed.Title = ReadTextSyndicationContent(reader); + continue; + case "subtitle": + feed.Description = ReadTextSyndicationContent(reader); + continue; + case "link": + SyndicationLink l = Item.CreateLink(); + ReadLink (reader, l); + feed.Links.Add (l); + continue; + case "id": + feed.Id = reader.ReadElementContentAsString(); + continue; + case "rights": + feed.Copyright = ReadTextSyndicationContent(reader); + continue; + } + } + } } else feed = new SyndicationFeed (); + reader.Read (); // </source> or <source ... /> return feed; } diff --git a/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog b/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog index 77df504..4351a68 100644 --- a/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog +++ b/class/System.ServiceModel.Web/System.ServiceModel.Syndication/ChangeLog @@ -1,3 +1,7 @@ +2010-06-09 Carlos Martín Nieto <car...@cmartin.tk> + + * Atom10ItemFormatter.cs: Correctly handle <source> tags + 2010-06-07 Carlos Martín Nieto <car...@cmartin.tk> * Rss20ItemFormatter.cs: Don't assume guids are permalinks
_______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list