加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 在自定义媒体类型中创建超媒体链接

发布时间:2020-12-16 07:49:36 所属栏目:百科 来源:网络整理
导读:我目前正在为RESTful api创建一组自定义媒体类型(例如application / vnd.mycompany.foo xml),我试图找出两种不同的暴露超媒体链接方式的优缺点. 如果我首先考虑其他媒体类型可能最好的起点是HTML. Html允许我创建链接,例如: image src="http://example.com/
我目前正在为RESTful api创建一组自定义媒体类型(例如application / vnd.mycompany.foo xml),我试图找出两种不同的暴露超媒体链接方式的优缺点.

如果我首先考虑其他媒体类型可能最好的起点是HTML. Html允许我创建链接,例如:

<image src="http://example.com/image.gif"/>
<a href="http://example.com/page.html"/>
<form action="http://example.com/page.html"/>
<link rel="stylesheet" type="text/css" href="theme.css" />

这里有趣的是,在某些情况下,某些特定标签具有url属性,然后是使用rel属性定义关系的通用链接标记.

在AtomPub中,还有一些资源链接在一起的方式

<collection href="http://example.org/blog/main" >
         <atom:title>My Blog Entries</atom:title>
         <categories href="http://example.com/cats/forMain.cats" />
</collection>

<atom:category scheme="http://example.org/extra-cats/" term="joke" />
<atom:entry>
   <link rel="edit" href="http://example.org/edit/first-post.atom"/>
</atom:entry>

我要问的问题是,何时使用具有关系的链接元素更有意义,何时将属性添加到现有元素更有意义.

例如AtomPub链接可能已经完成

<collection>
      <link rel="source" href="http://example.org/blog/main"/>
         <atom:title>My Blog Entries</atom:title>
         <categories>
                <link rel="source" href="http://example.com/cats/forMain.cats"/>
         </categories>
</collection>

<atom:category term="joke">
     <link rel="scheme" href="http://example.org/extra-cats/"/>
<atom:category>
<atom:entry edit="http://example.org/edit/first-post.atom"/>

通常情况下,在写这个问题时,答案似乎显而易见.必需的链接作为属性公开,可选的链接作为元素公开.但是,我非常有兴趣听取其他人对他们认为如何表示链接的看法.

我对 XHTML 2的喜欢是 every element could have a link.

为什么不利用XLink来实现相同的功能呢?那样,没必要选择.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读