不按字母顺序写rdf文件 [英] Write rdf file without Alphabetical

查看:72
本文介绍了不按字母顺序写rdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写RDF

我有一个RDF模型,我想将其写入文件中.结果将是:

I have a model RDF and I want write it in a file. This would be the result:

@prefix dc:      <http://purl.org/dc/elements/1.1/> .
@prefix legal:   <http://www.linked-usdl.org/ns/usdl-legal#> .
@prefix foaf:    <http://xmlns.com/foaf/0.1/> .
@prefix vann:    <http://purl.org/vocab/vann/> .
@prefix org:     <http://www.w3.org/ns/org#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix price:   <http://www.linked-usdl.org/ns/usdl-price#> .
@prefix usdl:    <http://www.linked-usdl.org/ns/usdl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dei:     <http://dei.uc.pt/rdf/dei#> .
@prefix gr:      <http://purl.org/goodrelations/v1#> .
@prefix skos:    <http://www.w3.org/2004/02/skos/core#> .

rdf:Standard_M1__Small_default
      rdfs:CPU "1 EC2 Compute Unit (1 virtual core with 1 EC2 Compute Unit)"^^xsd:string ;
      rdfs:RAM "1.7"^^xsd:float ;
      rdfs:Platform "32-bit"^^xsd:string ;
      rdfs:Storage "160"^^xsd:float .
      rdfs:IOPerformance "Moderate"^^xsd:string ;
      rdfs:EBS-OptimizedAvailable
              "false"^^xsd:boolean ;
      rdfs:OS "Linux/UNIX"^^xsd:string ;
      rdfs:Cost "0.08"^^xsd:float ;

但是,当执行model.write(out,lang);时,三元组按字母顺序排列(CPU,COST,ESB ...).当我创建模型时,将属性按我想要的顺序工作.但是当我编写模型时,它是按字母顺序排列的.如何忽略按字母顺序编写RDF模型的顺序?另一个问题,这个rdf文件正确吗?

But, when execute model.write(out, lang);, the triples are in alphabetical order (CPU,COST, ESB...). When I create the model, put the properties in the order I want and work. But when i write the model, it is arranges in alphabetical order. How can I disregard the alphabetical order to write the RDF model? Another question, this rdf file is correct?

谢谢.

推荐答案

RDF不合法

末尾缺少.

您问题中的RDF文件格式不正确.像

The RDF isn't legal

Missing . at end

Your RDF file in the question isn't well formed. A form like

s p1 o1 ;
  p2 o2 ;
  p3 o3 .

应以句号结尾.您似乎只向我们显示了文件的前几行.

Should end with a period. It looks like you might be showing us just the first few lines of your file.

从技术上讲,这可能不是禁止的,但是在某些序列化中,RDF名称空间中实际上不是RDF词汇的术语会引起警告,因此,像rdf:Standard_M1__Small_defaultrdfs:Platform这样的术语可能不是一个好主意.例如,请参见

This might not technically be prohibited, but in some serializations, terms in the RDF namespace that aren't actually RDF vocabulary will cause warnings, so terms like rdf:Standard_M1__Small_default and rdfs:Platform are probably a bad idea. E.g., see

5.1 RDF命名空间和词汇

RDF词汇表由该命名空间名称标识,并由 仅以下名称中的一个:…未定义任何其他名称,并且 遇到时应生成警告,否则应 表现正常.

5.1 The RDF Namespace and Vocabulary

The RDF Vocabulary is identified by this namespace name and consists of the following names only: … Any other names are not defined and SHOULD generate a warning when encountered, but should otherwise behave normally.

顺序无关紧要

RDF是基于 graph 的数据表示形式. RDF图是一个三元组的 set ,并且集合没有顺序.相同的RDF图可以以许多不同的方式进行序列化. Turtle 比某些格式更具人类可读性和可写性,但这只是无序数据格式的一种表示形式.由于它是无序的数据表示形式,因此没有真正的理由让实现记住您添加内容的顺序.因此,可能没有简单的方法来维护序列化的任何特定顺序.

The order doesn't matter

RDF is a graph based data representation. An RDF graph is a set of triples, and sets don't have order. The same RDF graph can be serialized in lots of different ways. Turtle is more human readable and writeable than some formats, but it's just a representation of an unordered data format. Because it's a unordered data representation, there's no real reason for an implementation to remember the order in which you added things. As such, there's probably no easy way to maintain any particular order for the serialization.

这篇关于不按字母顺序写rdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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