简体   繁体   English

为什么W3C RDF验证器用自己的RDF URI替换?

[英]Why does the W3C RDF validator replace the RDF URI with its own?

Let us say that we input the following RDF code to the W3C RDF validator at http://www.w3.org/RDF/Validator/ . 假设我们在http://www.w3.org/RDF/Validator/上向W3C RDF验证器输入以下RDF代码。

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:uni="http://www.example.org/uni-ns#">

  <rdf:Description rdf:about="949352">
    <uni:name>Grigoris Antoniou</uni:name>
    <uni:title>Professor</uni:title>
  </rdf:Description>
</rdf:RDF>

Once I ask to parse the RDF code, I find that in the triples, the RDF URI has been replaced with the own URI of the validator. 一旦我要求解析RDF代码,我发现在三元组中,RDF URI已被替换为验证器的自己的URI。

在此输入图像描述

Should not the subject of the triples be http://www.w3.org/1999/02/22-rdf-syntax-ns#949352 ? 三元组的主题不应该是http://www.w3.org/1999/02/22-rdf-syntax-ns#949352吗?

Why does the validator do this? 为什么验证器会这样做?

The rdf:about attribute takes an IRI as value. rdf:about属性将IRI作为值。

You have 949352 as value, which is a relative IRI. 您有949352作为值,这是一个相对IRI。 It gets resolved to the IRI of the base document (which is the validator in your case). 它被解析为基础文档的IRI(在您的情况下是验证器)。

You could, for example, provide an absolute IRI (example 1), or specify the xml:base (example 2). 例如,您可以提供绝对IRI(示例1),或指定xml:base (示例2)。

Example 1: 例1:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:uni="http://www.example.org/uni-ns#">

  <rdf:Description rdf:about="http://my-site.example.com/my-page/949352">
    <uni:name>Grigoris Antoniou</uni:name>
    <uni:title>Professor</uni:title>
  </rdf:Description>
</rdf:RDF>

Example 2: 例2:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:uni="http://www.example.org/uni-ns#"
    xml:base="http://my-site.example.com/my-page/">

  <rdf:Description rdf:about="949352">
    <uni:name>Grigoris Antoniou</uni:name>
    <uni:title>Professor</uni:title>
  </rdf:Description>
</rdf:RDF>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM