Note: This scenario has been moved over to the GPII wiki.

Scenario

Martha’s preferred language is English, so when a TV programme is not in English, she wants English subtitles. Between 6 a.m. and 6 p.m., the subtitles should be extra large, but when her eyes get tired, she wants them to be even larger. During the day, i.e. between 9 a.m. and 7 p.m., the TV’s default volume is loud, but at other times, a medium volume is OK. The TV’s brightness level also depends on the time of day: it should be at maximum brightness until 6 p.m. but at 80% of its maximum brightness in the evenings.

This is represented by the following user profile, formatted as comma-separated values (CSV).

Name, Condition, Probability, Value

http://gpii.org/ns/up/preferred-lang, , 1, en

http://gpii.org/ns/up/show-subtitles, value('http://gpii.org/ns/tv/program-lang') == 'en', 1, false

http://gpii.org/ns/up/show-subtitles, value('http://gpii.org/ns/tv/program-lang') != 'en', 1, true

http://gpii.org/ns/up/subtitle-font-size, value('http://gpii.org/ns/time/local-time') >= '06:00:00' && value('http://gpii.org/ns/time/local-time') <= '18:00:00', 1, x-large

http://gpii.org/ns/up/subtitle-font-size, value('http://gpii.org/ns/time/local-time') > '18:00:00' && value('http://gpii.org/ns/time/local-time') < '06:00:00', 1, xx-large

http://gpii.org/ns/up/volume, value('http://gpii.org/ns/time/local-time') >= '09:00:00' && value('http://gpii.org/ns/time/local-time') <= '17:00:00', 1, loud

http://gpii.org/ns/up/volume, value('http://gpii.org/ns/time/local-time') > '22:00:00' && value('http://gpii.org/ns/time/local-time') < '09:00:00', 1, medium

http://gpii.org/ns/up/tv-brightness-level, value('http://gpii.org/ns/time/local-time') >= '08:00:00' && value('http://gpii.org/ns/time/local-time') <= '18:00:00', 1, 100

http://gpii.org/ns/up/tv-brightness-level, value('http://gpii.org/ns/time/local-time') > '18:00:00' && value('http://gpii.org/ns/time/local-time') < '08:00:00', 1, 80

This format uses 4-tuples (or triples with a probability) to represent preferences. The name is a URI, the condition is an ECMAScript expression that evaluates to true or false (this syntax replaces the XPath 2.0 value comparisons using eq, ne, lt, le, gt, ge from a previous version of this scenario). The probability is a number between 0 and 1 (e.g. 0.5); the default value is 1.

Some notes on the names and values:

A format with 4-tuples (or triples with a probability) is preferred over a format that uses five or more tuples, like the following example, which specifies the device separately:

<preference
  name="http://gpii.org/ns/up/brightness-level"
  condition="value('http://gpii.org/ns/time/local-time') >=  '08:00:00' && value('http://gpii.org/ns/time/local-time') <=  '18:00:00'"
  device="http://gpii.org/ns/device/tv"
  probability="1"
  value="100" />

This approach makes it easier to filter properties or preferences for a specific device. The proposed format - based on 4-tuples - treats "device" and "application" as part of the condition, among other contextual conditions.

In this approach, different devices are part of the context (expressed in a device profile). It may be one property (http://.../device) or multiple properties (e.g. http://.../device-categorie, http://.../device-model, http://.../device-serial-number, etc.).

Only the user profiles need conditions. The contextual profiles (device, application, environment, etcetera) describe occurrences of real contexts of use. These contextual profiles don't need conditions. In a device profile, 'tv', 'mobile', and 'kiosk' can occur as possible values for a property (e.g. http://.../device). In an application profile, we can have any number of ATs listed as multiple occurrences of a property (e.g. http://.../assistive-tech). If a property name occurs multiple times, all listed values are assumed. So one property may have multiple values. In Dublin Core, this is the same. One document may have multiple authors by listing all of them as separate <dc:creator> statements.

An alternative approach - avoiding conditionals but keeping all the same info using refined terms

This image shows Martha has a profile with redundant metadata:

Profile-full

Without putting in a long explanation, ....

This version includes three possibilities:
1. The properties are all in the registry so the profile references them within the registry
2. Some properties are in the registry and some are ones that we use at 'our place' so they are just in a namespace we maintain. We refer to it as shown below.
3. No properties used are in the registry but they are all defined within two namespaces that are not in the registry but in the profile these places are identified and two prefixes are added to property-names to show where to find definitions, eg dc:language would lead to a lookup in the dc namespace, etc.

The conditional is not in the declaration of needs but a system, as ever, will be designed to test the condition and depending on if it is satisfied, the declaration will be recognised and implemented or ignored.

Device Profile

Below is a device profile for a TV set. Some properties are static, some may change during a session (e.g. the current channel). This type of profile consists of simple name-value pairs without conditions or probabilities.

Name, Value

http://wurfl.org/ns/wurfl/brand-name, 'Sony'

http://wurfl.org/ns/wurfl/model-name, 'Bravia XY'

http://wurfl.org/ns/wurfl/resolution-width, 1400

http://wurfl.org/ns/wurfl/resolution-height, 768

http://wurfl.org/ns/wurfl/physical-screen-width, '80cm'

http://wurfl.org/ns/wurfl/physical-screen-height, '45cm'

http://gpii.org/ns/tv/current-channel, 'CNN'

http://gpii.org/ns/tv/program-lang, 'fr'

Context Profile

Below is a context profile:

Name, Value

http://gpii.org/ns/time/local-time, '19:25:00'

Using the Profiles

With the above profiles, we can already do some basic adaptations:

So Martha will be watching the French TV program with English subtitles (if they are available), displayed in xx-large font size; the TV will use a medium sound value (unless Martha changes the volume) and 80% brightness.

XML and JSON Representations

The CSV represenation can be converted into XML and JSON. For example, the user profile in the first section of this page could be represented as follows (representations generated with some simple JavaScript code):

JSON:

[
{ "name" : "http://gpii.org/ns/up/preferred-lang",
"condition" : "",
"probability" : "1",
"value" : "en"
},
{ "name" : "http://gpii.org/ns/up/show-subtitles",
"condition" : "value('http://gpii.org/ns/tv/program-lang') == 'en'",
"probability" : "1",
"value" : "false"
},
{ "name" : "http://gpii.org/ns/up/show-subtitles",
"condition" : "value('http://gpii.org/ns/tv/program-lang') != 'en'",
"probability" : "1",
"value" : "true"
},
{ "name" : "http://gpii.org/ns/up/subtitle-font-size",
"condition" : "value('http://gpii.org/ns/time/local-time') >= '06:00:00' && value('http://gpii.org/ns/time/local-time') <= '18:00:00'",
"probability" : "1",
"value" : "x-large"
},
{ "name" : "http://gpii.org/ns/up/subtitle-font-size",
"condition" : "value('http://gpii.org/ns/time/local-time') > '18:00:00' && value('http://gpii.org/ns/time/local-time') < '06:00:00'",
"probability" : "1",
"value" : "xx-large"
},
{ "name" : "http://gpii.org/ns/up/volume",
"condition" : "value('http://gpii.org/ns/time/local-time') >= '09:00:00' && value('http://gpii.org/ns/time/local-time') <= '17:00:00'",
"probability" : "1",
"value" : "loud"
},
{ "name" : "http://gpii.org/ns/up/volume",
"condition" : "value('http://gpii.org/ns/time/local-time') > '22:00:00' && value('http://gpii.org/ns/time/local-time') < '09:00:00'",
"probability" : "1",
"value" : "medium"
},
{ "name" : "http://gpii.org/ns/up/tv-brightness-level",
"condition" : "value('http://gpii.org/ns/time/local-time') >= '08:00:00' && value('http://gpii.org/ns/time/local-time') <= '18:00:00'",
"probability" : "1",
"value" : "100"
},
{ "name" : "http://gpii.org/ns/up/tv-brightness-level",
"condition" : "value('http://gpii.org/ns/time/local-time') > '18:00:00' && value('http://gpii.org/ns/time/local-time') < '08:00:00'",
"probability" : "1",
"value" : "80"
}
]

XML (without escaping <, >, & etcetera for readability):

<preference name="http://gpii.org/ns/up/preferred-lang" condition="" probability="1" >en<preference/>
<preference name="http://gpii.org/ns/up/show-subtitles" condition="value('http://gpii.org/ns/tv/program-lang') == 'en'" probability="1" >false<preference/>
<preference name="http://gpii.org/ns/up/show-subtitles" condition="value('http://gpii.org/ns/tv/program-lang') != 'en'" probability="1" >true<preference/>
<preference name="http://gpii.org/ns/up/subtitle-font-size" condition="value('http://gpii.org/ns/time/local-time') >= '06:00:00' && value('http://gpii.org/ns/time/local-time') <= '18:00:00'" probability="1" >x-large<preference/>
<preference name="http://gpii.org/ns/up/subtitle-font-size" condition="value('http://gpii.org/ns/time/local-time') > '18:00:00' && value('http://gpii.org/ns/time/local-time') < '06:00:00'" probability="1" >xx-large<preference/>
<preference name="http://gpii.org/ns/up/volume" condition="value('http://gpii.org/ns/time/local-time') >= '09:00:00' && value('http://gpii.org/ns/time/local-time') <= '17:00:00'" probability="1" >loud<preference/>
<preference name="http://gpii.org/ns/up/volume" condition="value('http://gpii.org/ns/time/local-time') > '22:00:00' && value('http://gpii.org/ns/time/local-time') < '09:00:00'" probability="1" >medium<preference/>
<preference name="http://gpii.org/ns/up/tv-brightness-level" condition="value('http://gpii.org/ns/time/local-time') >= '08:00:00' && value('http://gpii.org/ns/time/local-time') <= '18:00:00'" probability="1" >100<preference/>