Copyright © 2008 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
Content Adaptation on the Mobile Web can be simplified by creating groups for those devices that share common characteristics. This WG Note defines an XML format, a group definition syntax and an extension to the DDR Simple API that can be used in the development of adaptive Mobile Web sites that exploit grouping.
This document is an editors' copy that has no official standing.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This is an Editorial Draft of a possible future W3C Note
Publication as an Editorial Draft does not imply endorsement by the Device Description Working Group or the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document is published as part of the W3C Mobile Web Initiative (MWI) by the Device Description Working Group. It is a deliverable as defined in the Charter of that group.
Please send comments to public-ddwg-comments@w3.org. This list is archived at http://lists.w3.org/Archives/Public/public-ddwg-comments/.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
1 Introduction
2 Device Grouping based on XML
2.1 The deviceStructures element
2.2 The vocabularies element
2.3 The vocabulary element
2.3.1 Attributes
2.4 The groups element
2.5 The group element
2.5.1 Attributes
2.6 The expression element
2.6.1 Expression Syntax
3 Extended Simple API
3.1 Initialization
3.2 Query Methods
4 Example
4.1 XML group definitions file
4.2 Java Code
The mobile handset market is innovative and dynamic but at the same time fragmented. The result is that there are thousands of different devices made by multiple manufacturers. Nonetheless the majority of handsets share common characteristics and can be grouped into families. For example, all the devices made by a manufacturer or all the devices that provide certain functionalities. Device Grouping is useful as it provides a higher level of abstraction (in an specific context), avoiding to work with specific device instances or models.
Device Grouping is also a valuable tool for content adaptation on the Mobile Web. One significative example could be the dynamic generation of a web page that includes a game download menu. The version of each game to be offered to the user could depend on the manufacturer and memory restrictions imposed by the target device, among others. This particular application would benefit from the existence of a grouping mechanism. The developer could define different groups of devices specifying certain conditions to be met by the 'vendor' and 'availableMemory' property values.
Our problem could also have been solved by means of 'if' statements in any programming language (using the DDR Simple API). However such approach is unflexible as a change in the Group conditions would also imply a change in the application logic. Furthermore, "harcoded" Groups defined using programming language statements do not promote knowledge reuse between companies and organizations.
In order to promote a more flexible approach for Device Grouping, this W3C Note proposes an XML format, a syntax for group expressions (based on boolean conditions over the DDR properties) and an extension to the DDR Simple API.
The device groups are defined in the XML format defined in the following sections. The XML infoset is described in XML Schema ... with each element in the http://www.w3.org/2008/05/structures
namespace.
Element | Attributes | Minimal Content Model |
---|---|---|
deviceStructures | None | (vocabularies)?, groups |
vocabularies | None | (vocabulary)+ |
vocabulary | iri, nsPrefix | EMPTY |
groups | None | group+ |
group | id | expression |
expression | None | PCDATA (See syntax) |
vocabularies
elementThis element is the parent element for all the vocabulary declarations in the XML document.
vocabulary
elementThe purpose of this element is the declaration of the vocabularies that will be used in the group definitions.
iri
The IRI of the vocabulary referenced. This attribute is mandatory.
nsPrefix
The namespace prefix assigned to the vocabulary. It will be used to reference qualified Property and Aspect names in expressions. This attribute is mandatory and there cannot be two vocabularies with the same prefix. Note that a vocabulary can be assigned the empty string as "" prefix, indicating that it will be the vocabulary used when properties are not fully qualified in expressions.
expression
elementThis element includes the boolean expression that defines a group.
Boolean expressions can be used to denote the conditions that a device and its aspects must satisfy in order to belong to an specific group. The formal syntax for those expressions is (in simple Extended Backus-Naur Form (EBNF) notation):
[1] | GroupExpr | ::= |
'not' GroupExpr
|
| '(' GroupExpr ')' | |||
| GroupExpr 'or' GroupExpr | |||
| GroupExpr 'and' GroupExpr | |||
| RelationalExpr | |||
[2] | RelationalExpr | ::= | PropertyDef '>' Number |
| PropertyDef '>=' Number | |||
| PropertyDef '<' Number | |||
| PropertyDef '<=' Number | |||
| PropertyDef '=='
Number |
Literal |
Boolean
| |||
| PropertyDef '!='
Number |
Literal |
Boolean
| |||
| PropertyDef 'contains' NumberEnum | |||
| PropertyDef 'contains' LiteralEnum | |||
[3] | PropertyDef | ::= | '[' PropertyNameDef ']' |
| '[' PropertyNameDef ',' AspectNameDef ']' | |||
[4] | PropertyNameDef | ::= | NsPrefix':'LocalPropertyName |
| LocalPropertyName | |||
[5] | AspectNameDef | ::= | NsPrefix':'LocalAspectName |
| LocalAspectName | |||
[6] | LocalPropertyName | ::= | NCName |
[7] | LocalAspectName | ::= | NCName |
[8] | NsPrefix | ::= | NCName |
[9] | NumberEnum | ::= | (' ( Number ( ',' Number )* )? ')' |
[10] | LiteralEnum | ::= | '(' ( Literal ( ',' Literal )* )? ')' |
[11] | Literal | ::= | '"' [^"]* '"' |
| "'" [^']* "'" | |||
[12] | Boolean | ::= | 'true' |
| 'false' | |||
[13] | Number | ::= |
Digits ('.' Digits?)? |
| '.' Digits
| |||
[14] | Digits | ::= | [0-9]+ |
The semantics of the boolean operators used are the same as those present in programming languages like Java.
The 'contains' clause returns true
if the corresponding enumerated property value includes at least the set of elements between brackets.
This note proposes two extensions to the DDR Simple API
<deviceStructures xmlns="http://www.w3.org/2008/05/structures"> <vocabularies> <vocabulary iri="http://www.w3.org/2008/01/ddr-core-vocabulary" nsPrefix="" /> <vocabulary iri="http://example.org/vocabulary" nsPrefix="ex"/> </vocabularies> <groups> <group id="NiceDevice"> <expression> ([imageFormatSupport,webBrowser] contains ('gif','jpeg') and [displayWidth] >= 240) or [ex:rendersTables,ex:webBrowser] == true and [inputDevices] contains ('touchScreen')) </expression> </group> <group id="XhtmlDevice"> <expression> [markupSupport] contains ('xhtmlmp10','xhtmlbasic10') </expression> </group> </groups> </deviceStructures>
Properties props = new Properties(); props.put("org.w3c.ddr.structures","file:///structuresExample.xml"); ServiceExt service = (ServiceExt)ServiceFactory.newService( "org.example.DDRServiceExt","http://www.w3.org/2008/01/ddr-core-vocabulary",props); Evidence evidence = service.newHttpEvidence(); evidence.put("User-Agent","Example Browser 1.1 on Example Device"); if(service.belongsTo(evidence,"XhtmlDevice")) { // Do Something } else { // Do other }