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 .
Timo Westkämper
  • 21,824
  • 5
  • 78
  • 111
M.M
  • 1,343
  • 7
  • 20
  • 49

3 Answers3

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/

Timo Westkämper
  • 21,824
  • 5
  • 78
  • 111
  • 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 : { } the error is : Error: {E201} rdf:about not allowed as attribute do you have any idea please about what is going ? – M.M Jul 09 '11 at 14:06
  • 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 : ` ` – Timo Westkämper Jul 10 '11 at 09:51
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.

ip.
  • 3,306
  • 6
  • 32
  • 42
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.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Ian Dickinson
  • 12,875
  • 11
  • 40
  • 67