W3C home > Mailing lists > Public > semantic-web@w3.org > July 2008

comparing XML and RDF data models

From: Maciej Gawinecki <mgawinecki@gmail.com>
Date: Tue, 01 Jul 2008 12:21:10 +0200
Message-ID: <486A0516.2010702@gmail.com>
To: semantic-web@w3.org

In one of the article comparing two data models: XML and RDF I found a 
statement stating that (I'm loosely citing from my memory):

   Searching XML with XPath query expression is easy if you know the
   schema of the document being quiried. However, the same query will not
   work any a document, which is differently structured, but contains
   equivalent information. This can be solved by usage of RDF model,
   which can be then queried with RDQL or SPARQL query.

Is that really true, that XPath-based XML search is limited due to its 
structure? Yes, that's why there is a great research on keyword-based 
quering of XML documents (not knowing schema in advance). But is it RDF 
really better for this issue ?

I will try to give a few example what I exactly mean. [Of course, I'm 
ommiting here the problem of knowning the name a tag/property/resource, 
only the structure can be different.] Let's see two XML documents:

   <Sensor>
     <name>Sensor220</name>
     <isLocatedNearBy>
       <Road>
         E330
       </Road>
     <isLocatedNearBy>
   </Sensor>

Here road value can be check through XPath expression: 
\\Sensor\isLocatedNearBy\Road

And let's see differently structured document (road defined by name 
property)

   <Sensor>
     <name>Sensor220</name>
     <isLocatedNearBy>
       <Road>
         <name>E330</name>
       </Road>
     <isLocatedNearBy>
   </Sensor>

With XPath expression: \\Sensor\isLocatedNearBy\Road\name

Or yet another one (road is ancestor tag to the sensor tag, not the oposite)

   <Road>
     <name>E330</name>
     <hasSensor>
       <Sensor>
         <name>Sensor 220</name>
       </Sensor>
     </hasSensor>
   </Road>

XPath: \\Road\name

The same problem would be with RDF. Let see the first model

   :Sensor220 :isLocatedNearBy :Road_E330 .

WHERE clause of SPARQL query would be then like a

   ?s :isLocatedNearBy :Road_E330 .

For other version we define a road with a specific value of hasName 
property:

   :Sensor220 :isLocatedNearBy :RoadXXX .
   :RoadXXX :hasName "E330" .

the SPARQL query part:

   ?s :isLocatedNearBy ?r .
   ?r :hasName "E330" .

or by analogy to the third XML representation (road "has" a sensor, not 
the opposite):

   :RoadXXX :hasName "E330" .
   :RoadXXX :hasSensor :Sensor220 .

the SPARQL query part:

   ?r :hasName "E330" .
   ?r :hasSensor ?s .

Can someone comment it ?

Thanks,
Maciej
Received on Tuesday, 1 July 2008 10:25:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:47:40 UTC