Write 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 ;
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?
Thanks.
The RDF isn't legal
Missing
.
at endYour RDF file in the question isn't well formed. A form like
Should end with a period. It looks like you might be showing us just the first few lines of your file.
Defining your own terms in the RDF and RDFS namespaces
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
andrdfs:Platform
are probably a bad idea. E.g., seeThe 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.