finally a bnode with a uri

ARC SPARQL Parser for PHP v0.2.0

ARC SPARQL parser updated to W3C Working Draft of 23 November 2005
I just uploaded a new version of ARC SPARQL Parser, my PHP-based SPARQL query parser. It has been updated to the W3C Working Draft 23 November 2005 grammar. As with the other ARC components, I tried to keep things simple. Here is a basic example of how the parser works and what type of result it produces:

Query definition:
$query='
  PREFIX foaf:   <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?name ?mbox WHERE { ?x foaf:name ?name ; foaf:mbox ?mbox } ORDER BY ASC(?name) LIMIT 10 OFFSET 20 ';

Parser instantiation and parsing:
$parser=new ARC_sparql_parser();
$parser->parse($query);
if(!$parser->get_errors()){
  $infos=$parser->get_infos();
}

The $infos array has the following structure:
Array (
 [query_type] => select
 [distinct] => 1
 [vars] => Array (
   [0] => name
   [1] => mbox
   [2] => x
  )

 [result_vars] => Array (
   [0] => name
   [1] => mbox
  )

 [datasets] => Array (
  )

 [patterns] => Array (
   [0] => Array (
     [type] => triples
     [triples] => Array (
       [0] => Array (
         [s] => Array (
           [type] => var
           [val] => x
          )

         [p] => Array (
           [type] => iri
           [val] => http://xmlns.com/foaf/0.1/name
          )

         [o] => Array (
           [type] => var
           [val] => name
          )
        )

       [1] => Array (
         [s] => Array (
           [type] => var
           [val] => x
          )

         [p] => Array (
           [type] => iri
           [val] => http://xmlns.com/foaf/0.1/mbox
          )

         [o] => Array (
           [type] => var
           [val] => mbox
          )
        )
      )
    )
  )

 [order_conditions] => Array (
   [0] => Array (
     [type] => expression
     [direction] => asc
     [expression] => Array (
       [type] => var
       [var] => name
       [modifier] =>
) ) ) [limit] => 10 [offset] => 20 )
The parser hasn't been tested very much yet, but knowing that RAP and Drupal folks are currently looking at my stuff in order to add SPARQL support to their toolkits, I thought it'd make sense to replace my crappy first version from April with something more usable.

Comments are disabled for this post.

Earlier Posts

Archives/Search

YYYY or YYYY/MM
No Posts found

Feeds