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

下面通过一个例子来解释 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 >

 

 

转载于:https://www.cnblogs.com/ajuanabc/archive/2008/02/15/2462946.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值