RDF POST arrays syntax Brainstorming

From n² wiki

Jump to: navigation, search


The aim is a syntax for a simple subset of RDF expressed as an associative array, so that html forms can submit values in a way that can be interpreted as RDF.

This is only supposed to be a common pattern - not to encompass all forms use, but hopefully it should cover quite a lot.

The structure is similar to RDF/XML


array(
	'resources' => array(
          /* Syntax accomodates a mix of styles:
            RDF/XML-like, where the top level key of a resource is a qname of either rdf:Description, or an rdf class type
           */
	    'foaf:Person' => array(
	        'rdf:about' => 'http://example.co.uk/#me',
		    'foaf:name@en' => 'John Smith',
                    'foaf:mbox' => 'john.smith@mail.com',
                    'bio:born^^gYear'=> '1976',
                    'foaf:homepage' => array('rdf:resource' => 'http://example.com/home'),
				),
			),
	  /* OR RDF/JSON - like, where the top level key is a uri. */

            'http://example.co.uk/#me' => array(
                              'http://www.w3.org/2000/01/rdf-schema#label' =>  'John Smith',
                              'http://www.w3.org/2000/01/rdf-schema#comment' => 'An exemplary person',
                                               )

		);

You can create structured arrays like this with html form widgets like:

<input name="resources[http://example.co.uk/#me][http://www.w3.org/2000/01/rdf-schema#label]" value="John Smith"/>

or

<input name="resources[foaf:Person][rdf:about]" value="http://example.co.uk/#me" type="hidden"/>
<input name="resources[foaf:Person][foaf:name]" value="John Smith"/>


  • the top level is 'resources' - this is allows differentiation between input that should be saved as RDF and input for some other purpose. (in my lib, I think I will let this top level key be optionally specified, defaulting to none).
  • Language typing is done by appending a @ and a language code to the predicate name
  • datatyping is done in the same way with ^^
  • multiple values for the same predicate can be done with a numeric array, eg:
    <input name="resources[foaf:Person][foaf:nick][0]" value="kwijibo"/>
  • top level resource keys can either be qnames (of either rdf:Description, or an rdf class type, or a uri).
  • predicate keys can be qnames or uris, and should contain any language or datatyping of the objects under them. This is because the object can only really be a flat value in most user-facing circumstances.

See the [Converters] library for PHP code

kwijibo

Personal tools