W3C home > Mailing lists > Public > www-rdf-interest@w3.org > October 2001

extracting statements from XML (again)

From: Mark Nottingham <mnot@mnot.net>
Date: Tue, 2 Oct 2001 23:54:21 -0700
To: www-rdf-interest@w3.org
Message-ID: <20011002235416.D1430@mnot.net>

I've been thinking some more about adorning schemas to enable the
extraction of statements[1]. To illustrate what I mean, imagine an
XML instance (or a fragment thereof):

  <widget name="thing">
    <stock-properties store="down-the-road">
      <price unit="dollars">1.95</price>

This fragment has a corresponding XML Schema fragment which might
look something like;

  <element name="widget">
        <element name="stock-properties">
              <element name="price">
                    <extension base="decimal">
                      <attribute name="unit" type="string"/>                   
              <element name="stock" type="nonNegativeInteger"/>
      <attribute name="store" type="string"/>

When an implementation runs across this, we'd like to extract
statements along these lines:

  @prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
  @prefix :  <http://example.com/inventory#> .

  <> a :Inventory ; 
     :location [ a :Store; :place "down-the-road" ] ; 
     :items [ a rdf:Bag ;    
              rdf:_1 [ a :Widget ;    
                      :name "thing" ;
                      :price [ :amount "1.95"; :unit "dollars" ] ;
                      :stock "5"
            ] .

There are a few ways to realise this. In some ways, the most
efficient way to do so would be to adorn the Schema directly; e.g.,

  <element name="stock" type="nonNegativeInteger" 

and so forth.

Here, the predicate is implicitly 'stock', and the object is the
result of evaluating the expression in the current context. We'd need
to come up with some syntax to refer to different constructs in the
RDF (so, as in this example, we could point the subject to the proper
place). This is just a shot in the dark, there are other ways that
this could be done; the idea is just to expoit the structure of the
schema to nominate the statement components.

Unfortunately, I'm led to believe that such adornment is illegal in
Schema. So, something like SAF[2] could be used to attach the
directives for extracting statements; this would still allow some
advantage to be taken from the schema's structure, if it's put into
the its appinfo. I can see two obvous ways to express this.

First, one could use XML-escaped n3 with some XML tags interspersed;
for example,
 :location [ a :Store; 
             :place "<xsl:value-of select="stock-properties/@store">" ] ; 

Alternatively, one could just spell the triples out, something like;

    <extract:predicate type="literal">

This would, of course, be more verbose in most cases.

This is all very similar to blindfold grammars[3], it's just a matter
of syntax, I suppose; if it's accepted that XML Schema is an
interesting and useful place to put this facility, something other
than BNF (for all its charms ;) might be good.

Thoughts? I'm not sure of what this looks like from a purist Schema
perspective (or a purist Semantic Web perspective, for that matter),
but I find the possibility of gathering statements from any XML in
such a manner intriguing and potentially very useful.

1. http://lists.w3.org/Archives/Public/www-rdf-interest/2001Sep/0060.html
2. http://www.extensibility.com/resources/saf.htm
3. http://www.w3.org/2001/06/blindfold/grammar

Mark Nottingham
Received on Wednesday, 3 October 2001 02:54:24 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:07:38 UTC