W3C home > Mailing lists > Public > www-rdf-interest@w3.org > October 2003

RE: modeling nested containers with items

From: Leo Sauermann <leo@gnowsis.com>
Date: Wed, 8 Oct 2003 18:31:15 +0200
To: "'DuCharme, Bob (LNG-CHO)'" <bob.ducharme@lexisnexis.com>, <www-rdf-interest@w3.org>
Message-ID: <004b01c38db9$9ea97e00$0501a8c0@ZION>

Hiu,

first:
RDF is a graph and you can express easier in the graph than in the
RDF/XML syntax. 

You have been barking at the wrong tree insofar as "Items" can be
"containers".
" ... that can each contain items and/or other containers ..."

Simple put:
- Containers contain resources.
- a resource can be anything
- a container is a resource.

You would usually use containers or collections to express such lists:
http://www.w3.org/TR/rdf-primer/#collections
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:s="http://example.org/students/vocab#">
   <rdf:Description rdf:about="http://example.org/courses/6.001">
      <s:students rdf:parseType="Collection">
            <rdf:Description
rdf:about="http://example.org/students/Amy"/>
            <rdf:Description
rdf:about="http://example.org/students/Mohamed"/>
            <rdf:Description
rdf:about="http://example.org/students/Johann"/>
      </s:students>
   </rdf:Description>
</rdf:RDF>

http://www.w3.org/TR/rdf-primer/#containers
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:s="http://example.org/students/vocab#">
   <rdf:Description rdf:about="http://example.org/courses/6.001">
      <s:students>
         <rdf:Bag>
            <rdf:li rdf:resource="http://example.org/students/Amy"/>
            <rdf:li rdf:resource="http://example.org/students/Mohamed"/>
            <rdf:li rdf:resource="http://example.org/students/Johann"/>
            <rdf:li rdf:resource="http://example.org/students/Maria"/>
            <rdf:li rdf:resource="http://example.org/students/Phuong"/>
         </rdf:Bag>
      </s:students>
   </rdf:Description>
</rdf:RDF>


have a look at this for a list without collecitons:

<rdf:Description rdf:about="http://yourname/id1">
	<container rdf:Resource="http://yourname/id2" />
</rdf:Description>
<rdf:Description rdf:about="http://yourname/id2">
	<hasItem><Item rdf:about="http://yourname/id32" /></hasItem>	
	<hasItem><Item rdf:about="http://yourname/id42" /></hasItem>	
	<hasItem><Item rdf:about="http://yourname/id62" /></hasItem>	
	<hasItem><Item rdf:about="http://yourname/id52" /></hasItem>
</rdf:Description>




I ususally represent File structures this way 
(this is an answer to the www.gnowsis.com query 
SELECT ?x, ?y WHERE (<file://leo.gnowsis.com/media/MP3/songs/> ?x ?y)
(?y ?p1 ?p2)
)
<rdf:RDF
    xmlns:j.0="http://www.gnowsis.org/ont/filesys/0.1#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:j.1="http://www.gnowsis.org/ont/data/0.1#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" >
  <rdf:Description rdf:about="file://leo.gnowsis.com/media/MP3/songs/">
    <rdf:type
rdf:resource="http://www.gnowsis.org/ont/filesys/0.1#Folder"/>
    <j.0:contains
rdf:resource="file://leo.gnowsis.com/media/MP3/songs/U2%20-%20one.mp3"/>
    <j.0:contains
rdf:resource="file://leo.gnowsis.com/media/MP3/songs/U2one.mp3"/>
  </rdf:Description>
  <rdf:Description
rdf:about="http://www.gnowsis.org/ont/filesys/0.1#Folder">
    <rdf:type
rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
    <j.1:definedByAdapter>true</j.1:definedByAdapter>
    <rdfs:subClassOf
rdf:resource="http://www.gnowsis.org/ont/filesys/0.1#FileSystemEntry"/>
    <rdfs:label xml:lang="en">Folder</rdfs:label>
  </rdf:Description>
  <rdf:Description
rdf:about="file://leo.gnowsis.com/media/MP3/songs/U2%20-%20one.mp3">
    <j.0:bytesize
rdf:datatype="http://www.w3.org/2001/XMLSchema#long">4418792</j.0:bytesi
ze>
    <rdf:type
rdf:resource="http://www.gnowsis.org/ont/filesys/0.1#File"/>
    <j.0:extension>.mp3</j.0:extension>
    <rdfs:label>U2 - one.mp3</rdfs:label>
    <j.0:filename>U2 - one.mp3</j.0:filename>
  </rdf:Description>
  <rdf:Description
rdf:about="file://leo.gnowsis.com/media/MP3/songs/U2one.mp3">
    <j.0:bytesize
rdf:datatype="http://www.w3.org/2001/XMLSchema#long">4418792</j.0:bytesi
ze>
    <rdf:type
rdf:resource="http://www.gnowsis.org/ont/filesys/0.1#File"/>
    <j.0:extension>.mp3</j.0:extension>
    <rdfs:label>U2one.mp3</rdfs:label>
    <j.0:filename>U2one.mp3</j.0:filename>
  </rdf:Description>
</rdf:RDF>


hth
Leo Sauermann
www.gnowsis.com


> -----Original Message-----
> From: www-rdf-interest-request@w3.org 
> [mailto:www-rdf-interest-request@w3.org] On Behalf Of 
> DuCharme, Bob (LNG-CHO)
> Sent: Wednesday, October 08, 2003 4:28 PM
> To: 'www-rdf-interest@w3.org'
> Subject: modeling nested containers with items
> 
> 
> 
> I'm having a hard time figuring out an RDF way to model 
> containers that can
> each contain items and/or other containers. A filesystem 
> directory/file
> structure and a bookmark folder/bookmark structure are good examples.
> Assuming that each container and each item can have properties (e.g.
> "created" in the example below), how could I represent the 
> following in RDF?
> My attempts at using RDF containers have been bumping into 
> those striping
> issues. Or is even attempting to use RDF here a case of 
> barking up the wrong
> tree? 
> 
> 
>    <container id="i1" created="20031001">
>       <item id="i2" created="20031001"/>         
>       <item id="i3" created="20031003"/>         
>       <container id="i4" created="20031002">
>          <item id="i5" created="20031002"/>          
>          <item id="i6" created="20031003"/>          
>          <item id="i7" created="20031001"/>          
>          <container id="i8" created="20031003">
>             <item id="i9" created="20031004"/>
>          </container>
>          <container id="i10" 20031004"/>
>       </container>
>    </container>
> 
> thanks,
> 
> Bob
> 
Received on Wednesday, 8 October 2003 12:30:53 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:52:02 GMT