讨论了 Atom 订阅源格式。
术语“Atom”适用于两个相关标准:
Web 订阅源允许客户机检查在 Web 站点上发布的更新。为提供 Web 订阅源,Web 站点以标准化的机器可读格式发布最新文章或内容的列表。此列表称为订阅源。然后,可以通过联合订阅源中内容的 Web 站点或通过订阅源阅读器程序下载订阅源。
Atom 订阅源格式具有定义完善的模式。订阅源包含多个条目,并且各条目与内容关联。内容可以内联,也可以在指定的链接上提供。内容具有关联的类型信息(即内容的 MIME 类型)。
有三种定义完善的类型,称为“文本”、“html”和“xhtml”。用户可以提供自己的遵守 Atom 规范规则的类型。
对于入站数据,Atom 数据处理程序会将 Atom 订阅源转换为定义完善的业务对象。如果订阅源包含内联内容,那么根据数据处理程序的配置设置,将调用已配置的数据处理程序来将内联内容转换为业务对象并在订阅源中设置该业务对象。您必须为对应于该内联内容的业务对象提供模式。
请考虑以下例子。订阅源中有两个条目。第一个条目的内容类型为 XML,另一个条目的内容类型为 JSON。输入数据应如下所示:
287 <?xml version="1.0" encoding="utf-8"?>
288 <feed xmlns="http://www.w3.org/2005/Atom">
289
290 <title>Example Feed</title>
291 <subtitle>A subtitle.</subtitle>
292 <link href="http://example.org/feed/" rel="self"/>
293 <link href="http://example.org/"/>
294 <updated>2003-12-13T18:30:02Z</updated>
295 <author>
296 <name>John Doe</name>
297 <email>johndoe@example.com</email>
298 </author>
299 <id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
300
301 <entry>
302 <content type="text/xml">
303 <p:Customer xmlns:p="http://www.ibm.com/crm" xmlns="http://www.ibm.com/crm">
304 <id>10</id>
305 </p:Customer>
306 </content>
307 <title>Atom-Powered Robots Run Amok</title>
308 <link href="http://example.org/2003/12/13/atom03"/>
309 <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
310 <updated>2003-12-13T18:30:02Z</updated>
311 <summary>Some text.</summary>
312 </entry>
313 <entry>
314 <content>
315 <content type="text/json">
316 {"firstName"="John","lastName"="Doe","id"="10"}
317 </content>
318 <type>text/json</type>
319 </content>
320 <title>Atom-Powered Robots Run Amok</title>
321 <link href="http://example.org/2003/12/13/atom03"/>
322 <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
323 <updated>2003-12-13T18:30:02Z</updated>
324 <summary>Some text.</summary>
325 </entry>
326
327 </feed>
您将需要提供会对应于先前显示的 Customer 的 XML 模式。该客户是内联内容条目。
您还将需要提供对应于先前显示的 JSON 数据的 XML 模式。该 JSON 数据也是内联内容条目。
对于出站数据,Atom 数据处理程序会将定义完善的业务对象转换为 Atom 订阅源。如果订阅源业务对象包含内联内容业务对象,那么根据数据处理程序的配置,将调用已配置的数据处理程序将内容中的业务对象转换为订阅源中的内联内容条目。您必须为对应于该内联内容的业务对象提供模式。
请考虑以下例子。有两个对应于内容条目的业务对象。一个业务对象是 Customer,另一个业务对象是 Order。Customer 业务对象必须在 Atom 订阅源中序列化为 XML,Order 必须在 Atom 订阅源中序列化为定界流。
Customer 业务对象:
它的序列化 XML:
<entry>
<content type="text/xml">
<p:Customer xmlns:p="http://www.ibm.com/crm"
xmlns="http://www.ibm.com/crm">
<id>10</id>
<firstName>John</firstName>
<lastName>Doe</lastName>
</p:Customer>
</content>
</entry>
Order 业务对象:
它的序列化定界流:
<entry>
<content type="text/delimited">
10,Television
输出数据将如下所示:
328 <?xml version="1.0" encoding="utf-8"?>
329 <feed xmlns="http://www.w3.org/2005/Atom">
330
331 <title>Example Feed</title>
332 <subtitle>A subtitle.</subtitle>
333 <link href="http://example.org/feed/" rel="self"/>
334 <link href="http://example.org/"/>
335 <updated>2003-12-13T18:30:02Z</updated>
336 <author>
337 <name>John Doe</name>
338 <email>johndoe@example.com</email>
339 </author>
340 <id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
341 <entry>
342 <content type="text/xml">
343 <p:Customer xmlns:p="http://www.ibm.com/crm"
344 xmlns="http://www.ibm.com/crm">
345 <id>10</id>
346 <firstName>John</firstName>
347 <lastName>Doe</lastName>
348 </p:Customer>
349 </content>
350 <title>Atom-Powered Robots Run Amok</title>
351 <link href="http://example.org/2003/12/13/atom03"/>
352 <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
353 <updated>2003-12-13T18:30:02Z</updated>
354 <summary>Some text.</summary>
355 </entry>
356 <entry>
357 <content type="text/delimited">
358 10,Television
359 </content>
360 <title>Atom-Powered Robots Run Amok</title>
361 <link href="http://example.org/2003/12/13/atom03"/>
362 <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
363 <updated>2003-12-13T18:30:02Z</updated>
364 <summary>Some text.</summary>
365 </entry>
366 <entry>
367 <title>Atom-Powered Robots Run Amok</title>
368 <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
369 <updated>2003-12-13T18:30:02Z</updated>
370 <summary>Some text.</summary>
371 </entry>
372 </feed>