N3 notation to RDF/XML
Asked Answered
E

3

5

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 . 
 crop:SomeValue a rdfs:Class; rdfs:subClassOf crops:AttributeValue .

 crop:SomeValue/7 a crops:SomeValue .

 crop:SomeValue a rdf:Property ; rdfs:range crops:SomeValue .
Eyecatching answered 7/7, 2011 at 14:47 Comment(0)
T
3

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/

Toh answered 7/7, 2011 at 16:6 Comment(2)
thanks for your post , you just come to rescue :) just one question please , I have to RDF validator, one form Jena and the other is the w3c validator: when I tried to validate the following RDF , it works fine on the Jena validator , but problems appear in the W3C validator , here is the RDF : {<rdf:Property rdf:about="example.org/crops/SomeValue"> <rdfs:range rdf:resource="example.org/crops/Attribute/Value" /> </rdf:Property>} the error is : Error: {E201} rdf:about not allowed as attribute do you have any idea please about what is going ?Eyecatching
You need to provide the rdf:RDF wrapper element, all the XML namespace declarations and about and resource need to refer to proper URIs, then the validator doesn't complain : <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/TR/rdf-schema/"> <rdf:Property rdf:about="http://example.org/crops/SomeValue"> <rdfs:range rdf:resource="http://example.org/crops/Attribute/Value" /> </rdf:Property> </rdf:RDF>Flight
I
2

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.

Ilona answered 7/7, 2011 at 16:8 Comment(0)
M
2

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

Martingale answered 8/7, 2011 at 20:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.