1

我有点困惑如何使用 RDFa (Lite)、schema.org 和 FOAF 来建模 writer-agent 关系。我什至不确定我是否需要 FOAF。

假设我出版了一本书,我是作家并由代理人代理。所以我们有两个人,一个是我,一个是代理。澄清一下,我的意图是链接代理作为作者的联系点,同时表明作者是,页面的主题:

<!-- the agent representing me -->
<div resource="/Writecorp/Michael Stern" vocab="http://schema.org/" typeof="Person">
    <span property="name">Michael Stern</span>
    <div property="memberOf">
        <div typeof="Organization">
            <span property="name">Writecorp Inc. agency</span>
        </div>
    </div>
</div>

<!-- the writer, me -->
<div rel="me" vocab="http://schema.org/" typeof="Person">
    <link rel="agent" property="contactPoint" href="/Writecorp/Michael Stern" />
    <span property="name">H. P. Lovecraft</span>
</div>

我从https://stackoverflow.com/a/19389163/441662<link>收集到的解决方案。

当我将它提供给RDFa 1.1 Distiller 和 Parser时,它显示以下输出:

@prefix ns1: <http://www.w3.org/ns/rdfa#> .
@prefix ns2: <http://schema.org/> .

<> ns2:me [ a ns2:Person;
            ns2:contactPoint </Writecorp/Michael Stern>;
            ns2:name "H. P. Lovecraft" ];
    ns1:usesVocabulary ns2: .

</Writecorp/Michael Stern> a ns2:Person;
    ns2:memberOf """

                Writecorp Inc. agency

        """;
    ns2:name "Michael Stern" .

[] a ns2:Organization;
    ns2:name "Writecorp Inc. agency" .
  • 它是否正确识别rel="me"?它显示ns1:me,但我在引用的命名空间词汇 schema.org 中找不到任何关于它的信息。我应该使用 FOAF 前缀然后使用foaf:me吗?我也找不到很多这方面的例子。
  • 如何将代理建模为联系点关系?根据 schema.org 和Google 的测试工具,aPerson是不允许的contactPoint

解决方案?

进一步提出的一种解决方案是拥有一个既是 aContactPoint又是 a 的实体Person,但Google 的验证器似乎不太喜欢它。

另一种可能的解决方案是让代理和写入器都指向同一个ContactPoint资源(请参阅https://stackoverflow.com/a/30055747/441662)。

关于rel="me",这来自一个微格式示例,并且对于 schema.org (然而,正如@unor 在他的回答中所说的那样)或 foaf 是不可能的。


/edit 7-5-2015:我针对这个问题提出了一个 GitHub问题。当我了解更多信息时,我会更新这篇文章......

4

2 回答 2

1

虽然agent是 Schema.org 属性,但它的域是Action(您似乎并不打算这样做)。而且它既不是 FOAF 属性也不是注册的链接类型(因此它不能在 HTML5 中使用)。所以我想你必须找到一个合适的属性。

me是链接类型,而不是 Schema.org 或 FOAF 属性。但是当您使用vocab时,RDFa 解析器假定它是默认词汇表(在您的情况下为 Schema.org)中的一个属性。我不确定您是否真的打算将其用作链接类型(正如您在非链接元素上的 RDFa 方式中使用的那样)。

(如果打算使用链接类型,可能的解决方案是使用prefix而不是vocab。这样,无前缀的值rel被解释为链接类型,前缀值被解释为属性。)

如果使用 Schema.org,这本书的类型将是Book. 你会是author这个Book如果 Schema.org 提供合适的属性来指定您的代理,
您必须检查可用属性Book(如果代理与您的工作相关,而不是您的人)或Person(或者如果它是您的业务)。Organization啊,我错过了代理应​​该是一个ContactPoint。现在,我怀疑 Schema.org 是否打算让这种类型也可以指代组织或个人,但我想没有什么能阻止你说某事是 aContactPoint an Organization

关于resource(或about):是的,通常最好为您的实体提供 URI,而不是使用空白节点。这样,您和其他人就可以在相同或不同的文档中对这些实体进行陈述。

因此,理想情况下,您将为每个实体提供一个 URI(包括您自己,与文档的 URI 不同)。

例如,在网页上http://example.com/lovecraft,您可以:

<body prefix="schema: http://schema.org/">

  <div typeof="schema:Person" resource="#me"></div>

  <div typeof="schema:Organization schema:ContactPoint" resource="#agent"></div>

  <div typeof="schema:Book" resource="#book-1"></div>

</body>

现在你的 URI 是http://example.com/lovecraft#me(这代表你,这个人,而不是关于你的页面),你的代理人的组织有 URI http://example.com/lovecraft#agent,你的书有 URI http://example.com/lovecraft#book-1

这允许您以各种方式对这些进行陈述,例如:

<body prefix="schema: http://schema.org/">

  <div typeof="schema:Person" resource="#me">
    <link property="schema:contactPoint" href="#agent" />
    <link property="schema:author" href="#book-1" />
  </div>

  <div typeof="schema:Organization schema:ContactPoint" resource="#agent"></div>

  <div typeof="schema:Book" resource="#book-1"></div>

</body>

要声明页面 ( http://example.com/lovecraft) 是关于您的 ( http://example.com/lovecraft#me),您可以等待 Schema.org 的mainEntity属性(包含在下一个版本中),和/或使用 Schema.org 的about属性,和/或使用 FOAF 的isPrimaryTopicOf属性

于 2015-05-05T12:13:17.423 回答
0

一种选择是让 agent 和 writer 都指向同一个ContactPoint资源。

这似乎有点工作。这允许适当的降价来格式化代理及其联系方式,同时让作者指向代理的联系方式。但是,这仍然没有正确地将代理作为作者的代表(即不要与我打交道,而是与我的经纪人打交道)。而且我不确定机器阅读器将如何处理这种情况。

<!-- the agent representing me -->
<div resource="/Writecorp/MichaelStern" vocab="http://schema.org/" typeof="Person">
    <span property="name">Michael Stern</span>
    <link property="contactPoint" href="/Writecorp/MichaelStern#contact" />
    <div resource="/Writecorp/MichaelStern#contact" vocab="http://schema.org/" typeof="ContactPoint">
        <meta property="name" content="Michael Stern" />
        <div>Phone:
            <span property="telephone">(540) 961-4469</span>
        </div>
        <div>
            <a property="email" href="mailto:michael.stern@writecorp.inc.agency.com">michael.stern@writecorp.inc.agency.com</a>
        </div>
    </div>
    <div property="memberOf">
        <div typeof="Organization">
            <span property="name">Writecorp Inc. agency</span>
        </div>
    </div>
</div>

<!-- the writer, me -->
<div vocab="http://schema.org/" typeof="Person">
    <link property="contactPoint" href="/Writecorp/MichaelStern#contact" />
    <span property="name">H. P. Lovecraft</span>
</div>

请注意,name属性 onContactPoint是元标记,而不是普通的 span 元素。这是为了防止重复名称输出,同时为机器阅读器提供一种仍然使用联系人名称填充其数据模型的方法。

RDFa 1.1 Distiller 和 Parser中的 Turtle 输出:

@prefix ns1: <http://www.w3.org/ns/rdfa#> .
@prefix ns2: <http://schema.org/> .

<> ns1:usesVocabulary ns2: .

</Writecorp/MichaelStern> a ns2:Person;
    ns2:contactPoint </Writecorp/MichaelStern#contact>;
    ns2:memberOf """

            Writecorp Inc. agency

    """;
    ns2:name "Michael Stern" .

</Writecorp/MichaelStern#contact> a ns2:ContactPoint;
    ns2:email <mailto:michael.stern@writecorp.inc.agency.com>;
    ns2:name "Michael Stern";
    ns2:telephone "(540) 961-4469" .

[] a ns2:Person;
    ns2:contactPoint </Writecorp/MichaelStern#contact>;
    ns2:name "H. P. Lovecraft" .

[] a ns2:Organization;
    ns2:name "Writecorp Inc. agency" .

/edit 7-5-2015:我针对这个问题提出了一个 GitHub问题。当我了解更多信息时,我会更新这篇文章......

于 2015-05-05T14:26:16.400 回答