Eric Prud'hommeaux

W3C RDF-ImpNotes

 

RDF Implementor's Notes

table of contents

about this document

nested RDF Example

graph

nested RDF map

XML

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/TR/WD-rdf-syntax#"
         xmlns:a="http://a#">
  <rdf:Description bagId="3B">
    <a:c rdf:ID="4p"><a:d rdf:bagId="5B"><a:e rdf:ID="6p">7s</a:e></a:d></a:c>
  </rdf:Description>
</rdf:RDF>

parsing steps

  1.    <?xml version="1.0"?>
    
    do nothing.
  2.    <rdf:RDF xmlns:rdf="http://www.w3.org/TR/WD-rdf-syntax#"
             xmlns:a="http://a#">
    
    Start a new RDF database.
  3.   <rdf:Description bagId="3B">
    
    Create a Description called "3B" to store reifications of the enclosed statements.
    Add description_pre to a list of aboutEachs.
    Create triple labeling the type of the bag.
    xxx Find list of subjects in "3B" (none).
    description_pre = new Description('3B', NULL, NULL, NULL);
        bagId = 'B1', about = NULL; aboutEach = NULL, aboutEachPrefix = NULL;
        containers.registerContainer(this, '3B'));
        createTriple('...type', '3B', '...Bag');
    
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','3B','http://www.w3.org/TR/WD-rdf-syntax#Bag').
  4.     <a:c rdf:ID="4p">
    
    propertyElt.
  5.                      <a:d rdf:bagId="5B">
    
    object - typedNode.
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','5B','http://www.w3.org/TR/WD-rdf-syntax#Bag').
  6.                                          <a:e rdf:ID="6p">
    
    propertyElt.
    C[-1]->addSubject('genid2')
    C[-3]->completeDescription({P[-2], S[-2], ID}) 
      container[-3] = '3B';
      subject[-2] = 'genid1';
      predicate[-2] = 'c';
      ID = 'genid2';
      reify('3B', {'c', 'genid1', 'genid2'});
    • triple('c','genid1','genid2').
    C[-1]->setTypeFor('genid2')
      type[-1] = 'd';
      {'#type','genid2','d'}
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','genid2','d').
    if (resource) C[-1]->addPredicateAndObject(tagName, resource)
        for each subjects                             # none
            db.addTriple(a:e, subject, (nonexistent) resource)
    
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_1','3B','4p').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#predicate','4p','c').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#subject','4p','2N').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#object','4p','genid2').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','4p','http://www.w3.org/TR/WD-rdf-syntax#Bag').
  7.                                                           7s
    
    object - string
    C[-2]->completeDescription({P[-1], S[-1], id|about (aboutEach?)}) 
      container[-2] = '5B';
      subject[-1] = 'genid2';
      predicate[-1] = 'e';
      reify('5B', {'e', 'genid2', '7s'});
    C[-2]->addSubject(id|about)
    for each attribute     (bagId, {attribute, id|about, value})
    
    • triple('e','genid2','7s').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_1','5B','6p').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#predicate','6p','e').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#subject','6p','genid2').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#object','6p','7s').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','6p','http://www.w3.org/TR/WD-rdf-syntax#Bag').
  8.                                                            </a:e>
    

  9.                                                                  </a:d>
    

  10.                                                                        </a:c>
    

  11.   </rdf:Description>
    

  12. </rdf:RDF>
    


Mozzila Cattest Example

This is a slight modification of the Mozilla cattest.rdf. I added IDs and bagIDs where I could to make it more clear what came from where. The real cattest.rdf produces a map where "BTop", "Top" and "Btag" are all genids.

graph

Mozilla Cattest map

XML

<r:RDF xmlns:r="http://w3.org/TR/1999/PR-rdf-syntax-19990105#"
     xmlns:d="http://purl.org/dc/elements/1.0/"  
     xmlns="http://directory.mozilla.org/rdf">
<Topic r:ID="Topic" r:bagID="bTopic">
  <tag r:ID="btag" catid="4365"/>
  <d:Title r:ID="bTitle">The Title</d:Title>
  <narrow r:resource="Top/Bookmarks" r:ID="bNarrow"/>
</Topic>
</r:RDF>

parsing steps

  1. <r:RDF xmlns:r="http://w3.org/TR/1999/PR-rdf-syntax-19990105#"
         xmlns:d="http://purl.org/dc/elements/1.0/"  
         xmlns="http://directory.mozilla.org/rdf">
    
    Start a new RDF database.
  2. <Topic r:ID="Topic" r:bagID="bTopic">
      <tag r:ID="btag" catid="4365"/>
      <d:Title r:ID="bTitle">The Title</d:Title>
      <narrow r:resource="Top/Bookmarks" r:ID="bNarrow"/>
    </Topic>
    </r:RDF>
    
    Create a Description called "pre" to store reifications of the enclosed statements.
    Add description_pre to a list of aboutEachs.
    Create triple labeling the type of the bag.
    Find list of subjects in "pre" (none).
    description_pre = new Description('pre', NULL, 'B1', NULL);
        bagId = 'pre', about = NULL; aboutEach = 'B1', aboutEachPrefix = NULL;
        containers.registerContainer(this, 'pre'));
        createTriple('...type', 'pre', '...Bag');
        subjects = containers.aboutEach(this, 'B1');
    
    reifications RDF generated supplied
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#type','file:/test.rdf#BTopic','http://w3.org/TR/1999/PR-rdf-syntax-19990105#Bag')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#type','file:/test.rdf#iTopic','http://directory.mozilla.org/rdfTopic')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#type','file:/test.rdf#Btag','http://w3.org/TR/1999/PR-rdf-syntax-19990105#Bag')
    • triple('http://directory.mozilla.org/rdfcatid','file:/test.rdf#genid1','4365')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#predicate','file:/test.rdf#genid2','http://directory.mozilla.org/rdfcatid')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#subject','file:/test.rdf#genid2','file:/test.rdf#genid1')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#object','file:/test.rdf#genid2','4365')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#type','file:/test.rdf#genid2','http://w3.org/TR/1999/PR-rdf-syntax-19990105#Statement')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#_1','file:/test.rdf#Btag','file:/test.rdf#genid2')
    • triple('http://directory.mozilla.org/rdftag','file:/test.rdf#iTopic','file:/test.rdf#genid2')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#predicate','file:/test.rdf#genid3','http://directory.mozilla.org/rdftag')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#subject','file:/test.rdf#genid3','file:/test.rdf#iTopic')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#object','file:/test.rdf#genid3','file:/test.rdf#genid2')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#type','file:/test.rdf#genid3','http://w3.org/TR/1999/PR-rdf-syntax-19990105#Statement')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#_1','file:/test.rdf#BTopic','file:/test.rdf#genid3')
    • triple('http://purl.org/dc/elements/1.0/Title','file:/test.rdf#iTopic','The Title')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#type','file:/test.rdf#iTopic','http://directory.mozilla.org/rdfTopic')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#predicate','file:/test.rdf#genid4','http://purl.org/dc/elements/1.0/Title')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#subject','file:/test.rdf#genid4','file:/test.rdf#iTopic')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#object','file:/test.rdf#genid4','The Title')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#type','file:/test.rdf#genid4','http://w3.org/TR/1999/PR-rdf-syntax-19990105#Statement')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#_2','file:/test.rdf#BTopic','file:/test.rdf#genid4')
    • triple('http://directory.mozilla.org/rdfnarrow','file:/test.rdf#iTopic','file:/test.rdf#Top/Bookmarks')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#predicate','file:/test.rdf#genid5','http://directory.mozilla.org/rdfnarrow')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#subject','file:/test.rdf#genid5','file:/test.rdf#iTopic')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#object','file:/test.rdf#genid5','file:/test.rdf#Top/Bookmarks')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#type','file:/test.rdf#genid5','http://w3.org/TR/1999/PR-rdf-syntax-19990105#Statement')
    • triple('http://w3.org/TR/1999/PR-rdf-syntax-19990105#_3','file:/test.rdf#BTopic','file:/test.rdf#genid5')

Split ACL Example

This example is based on the http://www.w3.org/schema/certHTMLv1/ schema but has aboutEaches defined both before and after thier target, "B1". This is to test the immediate container completion feature.

graph

ACL RDF map

XML

<?xml version="1.0"?>
<rdf:RDF
 xmlns:rdf="http://www.w3.org/TR/WD-rdf-syntax#"
 xmlns:s="http://www.w3.org/schema/certHTMLv1/">
   <rdf:Description rdf:aboutEach="#B1" bagId="pre">
      <s:hasAccessTo rdf:resource="http://resource/a" rdf:ID="hata"/>
   </rdf:Description>
   <rdf:Bag ID="B1">
      <rdf:li>
         <s:resourceAccessRule rdf:ID="U1" rdf:bagId="U1B" access="access1" accessor="http://user1"/>
      </rdf:li>
      <rdf:li>
         <s:resourceAccessRule rdf:ID="U2" rdf:bagId="U2B" access="access2" accessor="http://user2"/>
      </rdf:li>
   </rdf:Bag>
   <rdf:Description rdf:aboutEach="#B1" bagId="post">
      <s:hasAccessTo rdf:resource="http://resource/b" rdf:ID="hatb"/>
   </rdf:Description>
</rdf:RDF>

parsing steps

  1. <?xml version="1.0"?>
    <rdf:RDF
     xmlns:rdf="http://www.w3.org/TR/WD-rdf-syntax#"
     xmlns:s="http://www.w3.org/schema/certHTMLv1/">
    
    Start a new RDF database.
  2.    <rdf:Description rdf:aboutEach="#B1" bagId="pre">
    
    Create a Description called "pre" to store reifications of the enclosed statements.
    Add description_pre to a list of aboutEachs.
    Create triple labeling the type of the bag.
    Find list of subjects in "pre" (none).
    description_pre = new Description('pre', NULL, 'B1', NULL);
        bagId = 'pre', about = NULL; aboutEach = 'B1', aboutEachPrefix = NULL;
        containers.registerContainer(this, 'pre'));
        createTriple('...type', 'pre', '...Bag');
        subjects = containers.aboutEach(this, 'B1');
    
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','pre','http://www.w3.org/TR/WD-rdf-syntax#Bag').
  3.       <s:hasAccessTo rdf:resource="http://resource/a" rdf:ID="hata"/>
    
    Create a node for each subject (objects in "pre" - still none) with the predicate and object found in the propertyElt.
    Because the Description container has aboutEach or aboutEachPrefix, store predicate and object for future additions to the aboutEach target ("hata").
    What do we do with the subject name "hata"? I suspect we do nothing.
    C[-3]->completeDescription({P[-2], S[-2], ID});   # no container 3 up the tag stack
                                                      # C[-1] = description_pre
    C[-1]->setTypeFor('4N');                          # no type 1 up the tag stack
    C[-1]->addSubject('hata')                         # ignored - no subject
    if (resource) C[-1]->addPredicateAndObject(tagName, resource) # hasAccessTo', 'http://resource/a'
        for each subjects in aboutEach                # none
            db.addTriple('http://www.w3.org/schema/certHTMLv1/hasAccessTo', subject, 'http://resource/a'
        if (aboutEach || aboutEachPrefix)
            subjectLess.add('http://www.w3.org/schema/certHTMLv1/hasAccessTo', 'http://resource/a')
    
  4.    </rdf:Description>
       <rdf:Bag ID="B1">
    
    create a Bag called "B1"
    bag_B1 = new Bag('B1')
        containers.registerContainer(this, 'B1'))
        createTriple('...type', 'B1', '...Bag')
    
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','B1','http://www.w3.org/TR/WD-rdf-syntax#Bag').
  5.       <rdf:li>
             <s:resourceAccessRule rdf:ID="U1" rdf:bagId="U1B" access="access1" accessor="http://user1"/>
          </rdf:li>
    
    Create a resourceAccessRule called "U1B".
    Add it to "B1".
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','U1B','http://www.w3.org/TR/WD-rdf-syntax#Bag').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_1','B1','U1').
    Create a subject node called "U1".
    Add its subjects to bag_B1. This will complete a statement for every aboutEach on "B1".
    description_pre = new Description('U1B', 'U1', NULL, NULL)
        bagId = 'U1B', about = 'U1'; aboutEach = NULL, aboutEachPrefix = NULL;
        containers.registerContainer(this, 'U1B'))
        createTriple('...#type', 'U1B', '...#Bag')
        subjects = ['U1']                             # single subject ('U1')
    C[-1]->addSubject('U1');                          # C[-1] = bag_B1
        for each container aboutEach.interestedIn("B1") (description_pre) {
            for each container.subjectLess.get (subjectLess_hata) {
                reify('pre', subjectLess.complete('U1'));
            }
        }
    
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','U1','http://www.w3.org/schema/certHTMLv1/resourceAccessRule').
    • triple('http://www.w3.org/schema/certHTMLv1/hasAccessTo','U1','http://resource/a').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#predicate','genid1','http://www.w3.org/schema/certHTMLv1/hasAccessTo').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#subject','genid1','U1').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#object','genid1','http://resource/a').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','genid1','http://www.w3.org/TR/WD-rdf-syntax#Statement').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_1','pre',genid1').
    for each attribute {create anonymous triple of the form {attribute, 'U1', value} and reify into 'U1B'}
    • triple('http://www.w3.org/schema/certHTMLv1/access','U1','access2').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#predicate','genid2','http://www.w3.org/schema/certHTMLv1/access').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#subject','genid2','U1').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#object','genid2','access1').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','genid2','http://www.w3.org/TR/WD-rdf-syntax#Statement').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_1','U1B','genid2').

    • triple('http://www.w3.org/schema/certHTMLv1/accessor','U1','http://user1').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#predicate','genid3','http://www.w3.org/schema/certHTMLv1/accessor').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#subject','genid3','U1').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#object','genid3','http://user1').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','genid3','http://www.w3.org/TR/WD-rdf-syntax#Statement').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_2','U1B','genid3').

  6.       <rdf:li>
             <s:resourceAccessRule rdf:ID="U2" rdf:bagId="U2B" access="access2" accessor="http://user2"/>
          </rdf:li>
    
    same as previous process substituting 'U2', 'U2B', 'access2', 'http://user2'
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','U2B','http://www.w3.org/TR/WD-rdf-syntax#Bag').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_2','B1','U2').

    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','U2','http://www.w3.org/schema/certHTMLv1/resourceAccessRule').
    • triple('http://www.w3.org/schema/certHTMLv1/hasAccessTo','U2','http://resource/a').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#predicate','genid4','http://www.w3.org/schema/certHTMLv1/hasAccessTo').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#subject','genid4','U1').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#object','genid4','http://resource/a').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','genid4','http://www.w3.org/TR/WD-rdf-syntax#Statement').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_2','pre',genid4').

    • triple('http://www.w3.org/schema/certHTMLv1/access','U2','access2').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#predicate','genid5','http://www.w3.org/schema/certHTMLv1/access').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#subject','genid5','U2').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#object','genid5','access2').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','genid5','http://www.w3.org/TR/WD-rdf-syntax#Statement').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_1','U2B','genid5').

    • triple('http://www.w3.org/schema/certHTMLv1/accessor','U2','http://user2').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#predicate','genid6','http://www.w3.org/schema/certHTMLv1/accessor').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#subject','genid6','U2').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#object','genid6','http://user2').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','genid6','http://www.w3.org/TR/WD-rdf-syntax#Statement').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_2','U2B','genid6').
  7.    </rdf:Bag>
       <rdf:Description rdf:aboutEach="#B1" bagId="post">
    
    Create a Description called "post".
    Add description_post to a list of aboutEachs.
    Create triple labeling the type of the bag.
    Find list of subjects in "post" ('U1' and 'U2').
    description_post = new Description('post', NULL, 'B1', NULL);
        bagId = 'post', about = NULL; aboutEach = 'B1', aboutEachPrefix = NULL;
        containers.registerContainer(this, 'post'));
        createTriple('...type', 'post', '...Bag');
        subjects = containers.aboutEach(this, 'B1');
    
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','post','http://www.w3.org/TR/WD-rdf-syntax#Bag').
  8.       <s:hasAccessTo rdf:resource="http://resource/b" rdf:ID="hatb"/>
    
    Create a node for each subject (objects in "pre" - 'U1' and 'U2') with the predicate and object found in the propertyElt.
    Store predicate and object for future additions to the aboutEach target ("hata").
    What do we do with the subject name "hatb"?
    C[-3]->completeDescription({P[-2], S[-2], ID});   # no container 3 up the tag stack
                                                      # C[-1] = description_pre
    C[-1]->setTypeFor('4N');                          # no type 1 up the tag stack
    C[-1]->addSubject('hatb');                        # hmmmm
    if (resource) C[-1]->addPredicateAndObject(tagName, resource) # hasAccessTo', 'http://resource/b'
        for each subjects
            db.addTriple('http://www.w3.org/schema/certHTMLv1/hasAccessTo', subject, 'http://resource/b'
        if (aboutEach || aboutEachPrefix)
            subjectLess.add('http://www.w3.org/schema/certHTMLv1/hasAccessTo', 'http://resource/b')
    
    • triple('http://www.w3.org/schema/certHTMLv1/hasAccessTo','U1','http://resource/b').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#predicate','genid7','http://www.w3.org/schema/certHTMLv1/hasAccessTo').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#subject','genid7','U1').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#object','genid7','http://resource/b').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','genid7','http://www.w3.org/TR/WD-rdf-syntax#Statement').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_1','post','genid7').

    • triple('http://www.w3.org/schema/certHTMLv1/hasAccessTo','U2','http://resource/b').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#predicate','genid8','http://www.w3.org/schema/certHTMLv1/hasAccessTo').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#subject','genid8','U2').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#object','genid8','http://resource/a').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#type','genid8','http://www.w3.org/TR/WD-rdf-syntax#Statement').
    • triple('http://www.w3.org/TR/WD-rdf-syntax#_2','post','genid8').
  9.    </rdf:Description>
    </rdf:RDF>
    
    all done
Last updated: 1999-01-15T20:56:39Z