[RDF] Queries, filters, context, trust, and more...

Jonas Liljegren jonas@liljegren.org
06 Oct 2000 18:59:30 +0200


And now the conclusion.  :-)

Jonas Liljegren <jonas@liljegren.org> writes:

> Let's say we have a P3P-like tree structure for person information:
> 
>   A --type--> Person
>   A --contact--> B
>   B --home--> C
>   C --phone--> "0012345"


> The person could have two home phone numbers.  You shouldn't have to
> write:
> 
>  $phone_str = $person->contact->[0]->home->[0]->phone->[0]->value;
> 
> This would be the first contact information (maby out of many
> sources), the first of the person home addresses, the first phone in
> that home.

The key here is the diffrence between the wanted answer and the
availible answer.  For every question, you would expect none, one,
some or all answers.

A query for a specific resource could specify the wanted properties
for that resource. As an example:

"Give me the resource of type Person with the name 'Jonas'."

  $res = $selection->node( type => $Person, name => 'Jonas' );

In addition to the local explicit properties, you will have general
default "expectations" inherited from the parent context. These will
include the preference to get the version of the answer believed to be
the correct one, and that you want to know what is true in this time
rather than some past or future time. The agent preferences will be
used in every session. The session preferences will state the contect
for the current discussion.


But what is the expection on the format of the result?  How many
results do we expect?  But first: what formats *can* we send?  Let's
say we want the phone number:

 $number = $persons->node( name => 'Jonas' )->phone;

There can be any number of 'Jonas' with any number of phone numbers
each.  The possible answers partly depends on the number of matches.

With one match we could:

 1. Return the literal resource
 2. Return the literal value
 3. Return a list of literal resources
 4. Return a list of literal values
 5. Return a selection containing the literal resource
 6. Return info about the number of matches
 7. Try to increase or decrease the number of matches by applying more
    preferences
 8. Ask caller for more/less restrictive parameters

If there are two matching persons with possibly several phone numbers
each, we could, in addition to the above, return trees or trimmed
trees.

 9. Construct metadata for each matched person about how that person
    matched the phone number query.  Return a selection of the matched
    persons.

10. Return a complete XML serialized model with the whole tree of the
    matched information.

11. Return the matched information as a perl hash tree

12. Return only the first nth levels of the tree



The detail of how this will function with a HTML user interface
depends on the SDL (presentation schema) that will be implemented at a
later stage.


In this stage, we will focus on items 1-6 for any combination of none
or more matches at any part of the tree.

These are the general responses:

  No such property: return undef
  No such resource: Throw an exception
  More than one match: Throw an exception


 1. Return the literal resource

  $number = $persons->node( name => 'Jonas' )->phone->li;

  The li "dynamic" property is used to get a specific resource from a
  container.  In this case, the selection resulting from the search on
  phone. li() without a parameter will get item 0 but throw an
  exception if there are more than one item.

  One match: Return the resource object 


 2. Return the literal value

  $number = $persons->node( name => 'Jonas' )->phone->value;

  All resources of type Literal has the content availible with the
  value() method.

  One match: Return the value


 3. Return a list of literal resources

  $numbers = $persons->node( name => 'Jonas' )->phone->list;

  The list() method returns a list with all the resources in the
  selection.  This _could_ be implemented by binding the list to a
  custom class, making it internally function like an enumeration /
  iterator.

  Any number of matches, including no property: Return the list
  No such resource: Throw an exception


 4. Return a list of literal values

  $numbers = $persons->node( name => 'Jonas' )->phone->value_list;

  The value_list() method returns a list with all the literal values in the
  selection.

  Any number of matches, including no property: Return the list
  No such resource: Throw an exception


 5. Return a selection containing the literal

  $numbers = $persons->node( name => 'Jonas' )->phone

  Since this is the default, theres not much to say...


 6. Return info about the number of matches

  $numbers = $persons->node( name => 'Jonas' )->phone->size



Exceptions:

Exceptions will be thrown in the form of a resource object containing
the information about what happend.

Each caller in the path can handle the exception with the help of the
context information.

A simple case for this would be then you want to get Jonas' phone
number, but there are two jonas.  The exception object will say that
the selection (of persons named jonas) has more than one item, and it
will point to the selection resource.  This would typicaly be handled
by listing the resources and letting the user chose one of them.  But
that's up to the agent.





To be continued...

-- 
/ Jonas  -  http://jonas.liljegren.org/myself/en/index.html