ZVON > Tutorials > RDF Tutorial
>> Example 12 << | Prev | Next | Contents

Description


RDF defines several container elements. The rdf:Alt element groups together resources which can be arbitrary substituted one for another. The order of resources is not important and it can contain duplicate resources. The individual resources are either individually numbered with rdf:_1, rdf:_2, rdf:_3 ... , or generalized form rdf:li can be used. In our case the library have several copies of the book Matilda. If a user wants to borrow the book, he just wants one of these copies, it does not matter which one.

Source


<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:lib="http://www.zvon.org/library">

     <lib:Author about="RD">
          <lib:firstName>Roald</lib:firstName>
          <lib:surname>Dahl</lib:surname>
               
          <lib:books>
               <rdf:Bag>
                    <rdf:_1 resource="Matilda"/>
                    <rdf:_2 resource="The BFG"/>
               </rdf:Bag>
          </lib:books> 
     </lib:Author>
          
     <rdf:Description about="JC">
          <rdf:type resource="http://www.zvon.org/library/Author"/>
          <lib:firstName>Joseph</lib:firstName>
          <lib:surname>Conrad</lib:surname>

          <lib:books>
               <rdf:Bag>
                    <rdf:li resource="Heart of Darkness"/>
                    <rdf:li resource="Lord Jim"/>
                    <rdf:li resource="The Secret Agent"/>
               </rdf:Bag>
          </lib:books> 
     </rdf:Description>
          
     <lib:Book about="Matilda" lib:pages="240">
          <lib:copy>
               <rdf:Alt>
                    <rdf:li resource="M124"/>
                    <rdf:li resource="M125"/>
                    <rdf:li resource="M126"/>
               </rdf:Alt>
          </lib:copy>
     </lib:Book>

     <rdf:Description about="The BFG" lib:pages="208">
          <rdf:type resource="http://www.zvon.org/library/Book"/>
          <lib:copy rdf:resource="T458"/>
     </rdf:Description>

     <lib:Book about="Heart of Darkness" lib:pages="110">
          <lib:copy rdf:resource="H16"/>
     </lib:Book>
      
      <lib:Book about="Lord Jim" lib:pages="314">
          <lib:copy rdf:resource="L187"/>
     </lib:Book>
      
     <lib:Book about="The Secret Agent" lib:pages="249">
          <lib:copy rdf:resource="T360"/>
     </lib:Book>
          
</rdf:RDF>

Output Top

Roald Dahl :
Matilda [ 240 pages; 3 copies ]
The BFG [ 208 pages; 1 copy ]

Joseph Conrad :
Heart of Darkness [ 110 pages; 1 copy ]
Lord Jim [ 314 pages; 1 copy ]
The Secret Agent [ 249 pages; 1 copy ]