0

I'm designing an ontology to represent in RDF electoral results from a voting event (election or referendum).

I defined the following classes:

  • election

  • electoralList

  • candidate

  • electoralBody

and the following properties:

  • totalVotesCasted with domain electoralBody and range int.

  • votesReceived, with domain electoralList / candidate and range int.

  • dateOfElection, with domain election and range date.

I envisioned my RDF as something like this:

<Election rdf:about="election1">
  <dateOfElection>2000-01-01</dateOfElection>
  <totalVotesCasted>60</totalVotesCasted>
  <electoralBody rdf:about="county1">
    <candidate rdf:about="Peter Parker">
     <votesReceived>12</votesReceived>
    </candidate>
    <candidate rdf:about="Clark Kent">
     <votesReceived>34</votesReceived>
    </candidate>
    <candidate rdf:about="Bruce Wayne">
     <votesReceived>14</votesReceived>
    </candidate>
  </electoralBody>
</rdf:Election>
<Election rdf:about="election2">
...
</rdf:Election>

Is this nested structure correct and advisable for structuring data in RDF?

CptNemo
  • 6,455
  • 16
  • 58
  • 107
  • There's not enough information. Your list of classes isn't consistent with the invalid RDF e.g. you list election as a class and Election as an XML element. The relationships you intend between classes aren't specified. If you must use RDF/XML rather than the more readableTurtle it should be valid XML and valid RDF/XML before anyone can advise you on an appropriate structure. – chrisis Nov 18 '16 at 14:05
  • Don't bother trying to write RDF/XML by hand. There's no need. Just write Turtle, and if you need to,you can convert to RDF/XML later. – Joshua Taylor Nov 22 '16 at 03:13

1 Answers1

0

As @chrisis says, you need to define the relations between your classes. I suggest you structure your RDF/XML like this (using a rdf collection to group the candidates for an electoral body):

<rdf:RDF
  xmlns="http://example.org/election#" 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
  <Election rdf:about="election1">
    <dateOfElection rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2000-01-01</dateOfElection>
    <totalVotesCasted rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">60</totalVotesCasted>
    <hasElectoralBody>
      <ElectoralBody rdf:about="county1">
        <hasCandidates rdf:parseType="Collection">
          <Candidate rdf:about="PeterParker">
            <votesReceived rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">12</votesReceived>
          </Candidate>
          <Candidate rdf:about="ClarkKent">
            <votesReceived rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">34</votesReceived>
          </Candidate>
          <Candidate rdf:about="BruceWayne">
            <votesReceived rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">14</votesReceived>
          </Candidate>
        </hasCandidates>
      </ElectoralBody>
    </hasElectoralBody>
  </Election>
  <Election rdf:about="election2">
    ...
  </Election>
</rdf:RDF>

Or (if in turtle):

@prefix : <http://example.org/election#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:election1 a :Election ;
    :dateOfElection "2000-01-01"^^xsd:date ;
    :totalVotesCasted 60 ;
    :hasElectoralBody :county1 .

:county1 a :ElectoralBody ;
    hasCandidates ( :PeterParker :ClarkKent :BruceWayne )
    .
:PeterParker a :Candidate ;
    :votesReceived 12 .
:ClarkKent a :Candidate ;
    :votesReceived 34 .
:BruceWayne a :Candidate ;
    :votesReceived 14 .
LarsG
  • 33
  • 1
  • 6