1

extending an rdf-vocabulary like FOAF is possible using XML-Schema but how can I use classes from such a vocabulary inside the definition? Basically I want to add new elements to the foaf:person and I want to make sure, that having those elements means that this object is a foaf:Person and nothing else.

<?xml version="1.0" encoding="UTF-8"?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/NewXMLSchema" xmlns:foaf="http://xmlns.com/foaf/0.1/" elementFormDefault="qualified">

<xs:import foaf:namespace="http://xmlns.com/foaf/0.1/" foaf:schemaLocation="http://xmlns.com/foaf/spec/index.rdf"/>

<xs:complexType ref="foaf:Person">
    <xs:sequence>
        <xs:element name="owns">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="device">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="HereBeSomething"></xs:element>
                            </xs:sequence>
                        </xs:complexType>   
                    </xs:element>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:element name="datapoints">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="point" type="xs:string"></xs:element>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
</xs:complexType>

the Complex Type is supposed t be the foaf:Person, but this arangement results in an errror:

"Multiple annotations found at this line: - s4s-att-must-appear: Attribute 'name' must appear in element 'complexType'. - s4s-att-not-allowed: Attribute 'ref' cannot appear in element 'complexType'."

How can I use Types from other RDF-Ontologies in the definition of my new Schema?

Lukas Ruge
  • 2,204
  • 3
  • 30
  • 42

1 Answers1

2

I would not go there. XML Schema isn't really a good tool for dealing with RDF data. Many people look at RDF's XML serialization and think, “oh so it's just like XML with some extra rdf:this and rdf:that attributes thrown in.” But that's deceptive.

RDF is a set of subject-predicate-object triples. There are multiple syntaxes for writing these triples down into files. RDF/XML is one of them; Turtle and N-Triples and RDFa are others.

The problem with RDF/XML is that there are many different ways of writing down the same set of triples in an RDF/XML file. For example, the following two snippets are exactly equivalent:

<foaf:Person rdf:about="#cygri">
    <foaf:nick>cygri</foaf:nick>
</foaf:Person>

<rdf:Description rdf:ID="cygri">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person">
    <foaf:nick>cygri</foaf:nick>
</foaf:Person>

In summary: My recommendation is not to use XML tools to process RDF data. Use RDF tools. To extend an RDF Schema like FOAF, use RDF Schema.

cygri
  • 9,412
  • 1
  • 25
  • 47