您的位置:首页 > Web前端

[Web开发] 微软的RSS协议扩展 - FeedSync 介绍 (2)

2008-02-15 08:17 603 查看
下面通过一个例子来解释 FeedSync 协议。 该例子讲述当没有数据一致性冲突发生的的时候,FeedSync 如何工作。

这是一个简单基于RSS协议的XML, 描述我今天的任务列表。


<?xml version="1.0" encoding="utf-8"?>


<rss version="2.0">


<channel>


<title>todolist.xml</title>


<description>Sample to do list</description>


<link>http://www.example.com/index.html</link>


<item>


<title>Pay Bills</title>


<description>Electric, Gas and Water Bills</description>


</item>


</channel>


</rss>



FeedSync 扩展在<item>下面加入了<sx:sync> 标签 以及 <sx:history> 标签


<?xml version="1.0"?>


<rss version="2.0" xmlns:sx="http://feedsync.org/2007/feedsync">


<channel>


<title>todolist.xml</title>


<description>Sample to do list</description>


<link>http://www.example.com/index.html</link>


<item>


<sx:sync id="101" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:11Z" by="fsRSSConvert.js"/>


</sx:sync>


<title>Pay Bills</title>


<description>Electric, Gas and Water Bills</description>


</item>


</channel>


</rss>



假设我有2台电脑(台式机和笔记本), 在台式电脑A 上我增加了“Buy groceries” 以及“Get car serviced” 任务项; 过了一会儿,我又在笔记本电脑B 上我增加了“Return books to library”以及“Get birthday gift for mother” 任务项。 这时,台式电脑A上的的XML 文件变成了


<item>


<sx:sync id="101" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:11Z" by="fsRSSConvert.js"/>


</sx:sync>


<title>Pay Bills</title>


<description>Electric, Gas and Water Bills</description>


</item>


<item>


<sx:sync id="ep1.100" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:11Z" by="A"/>


</sx:sync>


<title>Buy groceries</title>


<description>Get milk and eggs</description>


</item>


<item>


<sx:sync id="ep1.101" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:12Z" by="A"/>


</sx:sync>


<title>Get car serviced</title>


<description>Needs oil change</description>


</item>

笔记本电脑B上的XML 文件就是


<item>


<sx:sync id="101" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:11Z" by="fsRSSConvert.js"/>


</sx:sync>


<title>Pay Bills</title>


<description>Electric, Gas and Water Bills</description>


</item>


<item>


<sx:sync id="ep2.100" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:12Z" by="B"/>


</sx:sync>


<title>Return books to library</title>


<description>2 books in total</description>


</item>


<item>


<sx:sync id="ep2.101" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:12Z" by="B"/>


</sx:sync>


<title>Get birthday gift for mother</title>


<description>She likes blue flowers</description>


</item>

当两个电脑都做数据同步之后,通过FeedSync协议,服务器上将会对两个XML进行合并,最终形成


<item>


<sx:sync id="101" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:11Z" by="fsRSSConvert.js"/>


</sx:sync>


<title>Pay Bills</title>


<description>Electric, Gas and Water Bills</description>


</item>


<item>


<sx:sync id="ep1.100" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:11Z" by="A"/>


</sx:sync>


<title>Buy groceries</title>


<description>Get milk and eggs</description>


</item>


<item>


<sx:sync id="ep1.101" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:12Z" by="A"/>


</sx:sync>


<title>Get car serviced</title>


<description>Needs oil change</description>


</item>


<item>


<sx:sync id="ep2.100" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:12Z" by="B"/>


</sx:sync>


<title>Return books to library</title>


<description>2 books in total</description>


</item>


<item>


<sx:sync id="ep2.101" updates="1" deleted="false" noconflicts="false">


<sx:history sequence="1" when="2007-11-29T06:27:12Z" by="B"/>


</sx:sync>


<title>Get birthday gift for mother</title>


<description>She likes blue flowers</description>


</item>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: