Re: Generated RDF conformant with good practise?

Howard Katz wrote:

> My XQuery script takes this particular book and programmatically produces
> the following RDF/XML:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <rdf:RDF xmlns:bibterm="http://www.book-stuff.com/terms/"
>          xmlns:dc="http://purl.org/dc/elements/1.0/"
>          xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
>     <rdf:Description rdf:about="http://www.book-stuff.com/bib">
>         <bibterm:book>
>             <rdf:Description>
>                 <bibterm:year>1994</bibterm:year>
>                 <dc:title>TCP/IP Illustrated</dc:title>
>                 <bibterm:author>
>                     <rdf:Description>
>                         <bibterm:last>Stevens</bibterm:last>
>                         <bibterm:first>W.</bibterm:first>
>                     </rdf:Description>
>                 </bibterm:author>
>             </rdf:Description>
>         </bibterm:book>
>     </rdf:Description>
> </rdf:RDF>

I don't think this is really quite what I would look for, Howard.  The 
reason is that you are saying that a "bib" has one (or more) "book" 
properties.  While this is feasible, I don't think it models what most 
of us think of in this regard.  We think that a bibliography (I assume 
that is what "bib" is supposed to be) contains or describes books.  The 
books are really resources to be described, not properties of the bib.

This is a typical kind of situation that prevents automatic translation 
of arbitrary xml.  In this case, there is a missing layer that would if 
present state what the relation is between a bib and a book.  Since it 
is missing, you have to supply it.  That is basically a little data 
modeling task you have to do.

Conversely, if you start out trying to design your xml document to be 
legal rdf, the exercise may help you understand better what you are 
trying to model.

Of course, upon more reflection, you may decide that a bib should indeed 
have "book" properties after all.  Then that part is ok the way you have it.

You also have another problem, because normally a "bib" element in the 
source should turn into a *type* (or class) called "bib", but you have 
it turning into an instance.  It is unlikely that is what you really 
want to do.  You need to come up with a unique uri that identifies the 
specific bib in question.

If you take this approach, your rdf would come out more like this 
(notice that there are alternatives to using rdf:Description that can be 
a bit more readable) -

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:bibterm="http://www.book-stuff.com/terms/"
    xmlns:dc="http://purl.org/dc/elements/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <bibterm:bib rdf:about="http://www.book-stuff.com/bib/bib2501">
       <bibterm:contains> <!-- explicit relation added -->
          <bibterm:book>
             <bibterm:year>1994</bibterm:year>
             <dc:title>TCP/IP Illustrated</dc:title>
             <bibterm:author>
                <rdf:Description>					
                   <bibterm:last>Stevens</bibterm:last>
                   <bibterm:first>W.</bibterm:first>
                </rdf:Description>
             </bibterm:author>
          </bibterm:book>
       </bibterm:contains>
    </bibterm:bib>
</rdf:RDF>

It is very enlightening to use the w3c rdf validator and set it to show 
you just the graph. This makes it much easier to pick up cases like this 
where you have created a property that you really want to be a 
(non-property) resource.

Cheers,

Tom P

-- 
Thomas B. Passin
Explorer's Guide to the Semantic Web (Manning Books)
http://www.manning.com/catalog/view.php?book=passin

Received on Thursday, 16 September 2004 02:02:15 UTC