为什么 W3C RDF 验证器将 RDF URI 替换为自己的? [英] Why does the W3C RDF validator replace the RDF URI with its own?

查看:76
本文介绍了为什么 W3C RDF 验证器将 RDF URI 替换为自己的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们将以下 RDF 代码输入到 W3C RDF 验证器 将 IRI 作为值.

您有 949352 作为值,这是一个相对 IRI.它被解析为基础文档的 IRI(在您的情况下是验证器).

例如,您可以提供绝对 IRI(示例 1),或指定 xml:base(示例 2).

示例 1:

<rdf:描述 rdf:about="http://my-site.example.com/my-page/949352"><uni:name>格里戈里斯·安东尼奥</uni:name><uni:title>教授</uni:title></rdf:描述></rdf:RDF>

示例 2:

<rdf:描述 rdf:about="949352"><uni:name>格里戈里斯·安东尼奥</uni:name><uni:title>教授</uni:title></rdf:描述></rdf:RDF>

Let us say that we input the following RDF code to the W3C RDF validator at http://www.w3.org/RDF/Validator/.

<?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.

Should not the subject of the triples be 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.

You have 949352 as value, which is a relative IRI. It gets resolved to the IRI of the base document (which is the validator in your case).

You could, for example, provide an absolute IRI (example 1), or specify the xml:base (example 2).

Example 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:

<?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>

这篇关于为什么 W3C RDF 验证器将 RDF URI 替换为自己的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆