1

添加 RDFa 非常有趣,但往往会使我的源代码几乎无法阅读(即使编辑器有不错的语法突出显示)。例如:

<div id="me" prefix="foaf: http://xmlns.com/foaf/0.1/ schema:
http://schema.org/Person" typeof="foaf:Person schema:Person"
resource="http://carlboettiger.info#me"> <p> <img property="foaf:depiction"
src="assets/img/carlboettiger.png" alt="Photo of Carl Boettiger"
style="float: right; margin: 10px 10px"/>
I am  <a property="foaf:homepage schema:url"
href="http://carlboettiger.info"><span property="foaf:name
schema:name"><span property="foaf:givenName schema:givenName">Carl</span>
<span property="foaf:familyName schema:familyName">Boettiger</span></span></a>, <span
property="schema:jobTitle">a graduate student</span> with <span property="foaf:knows"><span
typeof="foaf:Person"><span property="foaf:name"><a property="foaf:homepage"
href="http://two.ucdavis.edu/%7Eme">Alan Hastings</a>
</span></span></span> in the <a property="foaf:workplaceHomepage"
href="http://www-eve.ucdavis.edu/eve/pbg/">Population Biology</a>
Ph.D program at<span property="schema:affiliation">UC Davis</span>,
working on <span property="foaf:interest">regime shifts</span>
in <span property="foaf:interest">ecology</span> and <span
property="foaf:interest">evolution</span>. Such shifts mark the most
dramatic events in <span property="foaf:interest">complex systems</span>

我一般不喜欢密集标记,因此我经常更喜欢用 markdown 编写,但这在添加 RDFa 标记的上下文中似乎是不可能的,例如这个例子。

似乎有人可能会利用空格来使其更具人类可读性。是否有任何现有的工具或约定?(下面的示例只是来自!fmtvim 中的自动换行,通常看起来不错,但在这种情况下似乎不知所措)。

4

1 回答 1

3
  • 您应该更喜欢使用广泛传播的本体而不是复制已经具有等价物的类或谓词(或者只产生 owl:equivalentClass 或 owl:sameAs 关系)
  • RDFa 1.1 中有许多您没有使用过的快捷方式,例如 vocab 或 rel 属性
  • 您可以使用缩进来美化标记

据此,您的页面可能如下所示:

<body prefix="schema: http://schema.org/"
      vocab="http://xmlns.com/foaf/0.1/">
    <p typeof="Person" resource="http://carlboettiger.info#me">
    <img property="depiction" style="float: right; margin: 10px 10px"
         src="assets/img/carlboettiger.png" alt="Photo of Carl Boettiger" />
    I am <a property="homepage schema:url" href="http://carlboettiger.info">
        <span property="name"><span property="givenName">Carl</span> <span property="familyName">Boettiger</span></span>
    </a>, a <span property="schema:jobTitle">graduate student</span> with
    <span rel="knows" typeof="Person">
        <span property="name"><a property="homepage" href="http://two.ucdavis.edu/%7Eme">Alan Hastings</a></span>
    </span> in the <a property="workplaceHomepage" href="http://www-eve.ucdavis.edu/eve/pbg/">Population Biology</a>
    Ph.D program at <span property="schema:affiliation">UC Davis</span>, working on
    <span rel="interest">
        <a href="http://en.wikipedia.org/wiki/Regime_shifts">regime shifts</a> in
        <a href="http://en.wikipedia.org/wiki/Ecology">ecology</a> and
        <a href="http://en.wikipedia.org/wiki/Evolution">evolution</a>.
        Such shifts mark the most dramatic events in <span>complex systems</span>
    </span>
    </p>
</body>
于 2012-12-04T20:39:19.003 回答