do not trust Atom10ItemFormatter
今日コミットしたAtom10ItemFormatter.csから抜粋:
// // WARNING: // This class is not for outputting ATOM 1.0 conformant XML. For example // it does not report errors with related to the following constraints: // - atom:entry elements MUST NOT contain more than one atom:link // element with a rel attribute value of "alternate" that has the // same combination of type and hreflang attribute values. // - atom:entry elements that contain no child atom:content element // MUST contain at least one atom:link element with a rel attribute // value of "alternate". //
まあどうせ意図的な動作なんだろう。以下、前者の実証サンプル:
SyndicationItem item = new SyndicationItem (); item.Links.Add (new SyndicationLink ( new Uri ("http://mono-project.com/Page1"), "alternate", "Page 1", "text/html", 0)); item.Links.Add (new SyndicationLink ( new Uri ("http://mono-project.com/Page2"), "alternate", "Page 2", "text/html", 0)); StringWriter sw = new StringWriter (); using (XmlWriter w = CreateWriter (sw)) new Atom10ItemFormatter (item).WriteTo (w);
出力がvalidなATOM 1.0ドキュメントかどうか確かめないとまずい人は、RelaxngValidatingReaderでも使って検証して下さいな。