Re: Generated RDF conformant with good practise?

On Wed, 15 Sep 2004, Howard Katz wrote:

>
> Hi all,
>
> I'd appreciate some feedback on something. I'm writing an tutorial-type
> article that shows how to use XQuery to transform a standard XML datafile
> (not RDF/XML) into RDF. The main focus of the article is on XQuery, but I
> need to make sure that my RDF is also correct and not atypical. Here's a
> snippet of the data I'm starting with (the "bib.xml" file that ships with
> the XQuery specification):
>
> <bib>
> 	...
> 	<book year="1994">
> 		<title>TCP/IP --- tcp --- Illustrated</title>
> 		<author><last>Stevens</last><first>W.</first></author>
> 		<publisher>Addison-Wesley</publisher>
> 		<price> 65.95</price>
> 	</book>
> 	...
> </bib>
>
> 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>
>

That looks fine to me Howard. Often you see rdf:parseType='Resource' 
being used instead of rdf:Description (i.e. where there are no types on the 
nodes) for brevity, but depending on your audience this might be more 
confusing than helpful. The result would be

  <?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:parseType="Resource">
                 <bibterm:year>1994</bibterm:year>
                 <dc:title>TCP/IP Illustrated</dc:title>
                 <bibterm:author rdf:parseType="Resource">
                         <bibterm:last>Stevens</bibterm:last>
                         <bibterm:first>W.</bibterm:first>
                 </bibterm:author>
         </bibterm:book>
     </rdf:Description>
</rdf:RDF>

which should give you exactly the same N-triples.

I guess the other thing you could do is put types nodes book and author 
(typed nodes are by convention capitalized).

hm, looking at it again, if it was me, I'd do something like this:

<rdf:RDF xmlns:bibterm="http://www.book-stuff.com/terms/"
          xmlns:dc="http://purl.org/dc/elements/1.0/"
          xmlns:foaf="http://xmlns.com/foaf/0.1/"
          xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

         <bibterm:Book><!--now a class -->
                  <bibterm:url rdf:resource="http://www.book-stuff.com/bib"/>
<!-- I'm not sure what this url refers to -->
                 <bibterm:year>1994</bibterm:year>
                 <dc:title>TCP/IP Illustrated</dc:title>
                 <bibterm:author>
                     <foaf:Person><!--just a suggestion :) -->
                         <bibterm:last>Stevens</bibterm:last>
                         <bibterm:first>W.</bibterm:first>
                     </foaf:Person>
                 </bibterm:author>
         </bibterm:Book>
  </rdf:RDF>

so now I've assumed the book itself is not the same as its url, but 
that it has an associated url (e.g like a foaf:homepage) - the url is 
not necessary by the way. I've made the book a typed node (which fits 
better with your xml I think), and there's no need for the 'book' 
predicate indirection from your first example.

I hope that makes sense!

Libby


> Here's an N-Triples view of the same information:
>
> <http://www.book-stuff.com/bib> <http://www.book-stuff.com/terms/book>
> _:jARP438894 .
> _:jARP438894 <http://www.book-stuff.com/terms/year> "1994" .
> _:jARP438894 <http://purl.org/dc/elements/1.0/title> "TCP/IP Illustrated" .
> _:jARP438894 <http://www.book-stuff.com/terms/author>  _:jARP438895 .
> _:jARP438895 <http://www.book-stuff.com/terms/last> "Stevens" .
> _:jARP438895 <http://www.book-stuff.com/terms/first> "W." .
>
> My basic question, given that I'm still fairly new to RDF, is: does this
> look like reasonably valid RDF to people, valid in the sense of not seeming
> too odd or unusual in some way, as well as being true to the intent of the
> original data? I basically want to make sure I'm not producing RDF that's at
> odds with what's considered good practise.
>
> TIA for any thoughts,
> Howard
>
>
>

Received on Thursday, 16 September 2004 09:47:09 UTC