开发者

N3 notation to RDF/XML

开发者 https://www.devze.com 2023-03-17 19:50 出处:网络
I have to sample N3 and I need to convert it to the corresponds RDF/XML format please , any help ? crop:AttributeValue a rdfs:Class .

I have to sample N3 and I need to convert it to the corresponds RDF/XML format please , any help ?

 crop:AttributeValue a rdfs:Class . 
 cr开发者_Python百科op:SomeValue a rdfs:Class; rdfs:subClassOf crops:AttributeValue .

 crop:SomeValue/7 a crops:SomeValue .

 crop:SomeValue a rdf:Property ; rdfs:range crops:SomeValue .


You need to specifiy a bit more info, e.g. like this

@prefix crop: <http://example.org/foo#> .
@prefix crops: <http://example.org/foo#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/TR/rdf-schema/> .

crop:AttributeValue a rdfs:Class . crop:SomeValue a rdfs:Class; rdfs:subClassOf crops:AttributeValue .

<http://example.org/foo#SomeValue/7> a crops:SomeValue .

crop:SomeValue a rdf:Property ; rdfs:range crops:SomeValue .

Replace the namespaces for crop and crops with the correct ones.

This would be the following in RDF/XML

<?xml version="1.0"?>
<rdf:RDF xmlns:rdfs="http://www.w3.org/TR/rdf-schema/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:crops="http://example.org/foo#">
    <rdfs:Class rdf:about="http://example.org/foo#SomeValue">
        <rdfs:subClassOf>
            <rdfs:Class rdf:about="http://example.org/foo#AttributeValue" />
        </rdfs:subClassOf>
        <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property" />
        <rdfs:range rdf:resource="http://example.org/foo#SomeValue" />
    </rdfs:Class>
    <crops:SomeValue rdf:about="http://example.org/foo#SomeValue/7" />
</rdf:RDF>

Here is an online tool for the conversion : http://www.rdfabout.com/demo/validator/


You should check first if you have a valid n3 representation of your data. For example you use a prefix named crop and a prefix named crops. Assuming that these are correct, you also need to define your prefixes (crop, crops, rdf, rdfs). A valid example would be:

@prefix crop: <http://crop.org> .
@prefix crops: <http://crops.org> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

crop:AttributeValue a rdfs:Class . crop:SomeValue a rdfs:Class; rdfs:subClassOf crops:AttributeValue .
crop:SomeValue a crops:SomeValue .
crop:SomeValue a rdf:Property ; rdfs:range crops:SomeValue .

For a validation and conversion you might than check out RDF About Validator. Alternatively you can use this tool as well.


If you're using Jena, there is a command-line tool rdfcat which can convert files between RDF/XML, N-triples and Turtle formats.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号