W3C

Device Description Structures

An expression language for the structured categorization of devices in content adaptation

W3C Working Draft Note 05 December 2008

This version:
http://www.w3.org/TR/2008/WD-dd-structures-20081205/
Latest version:
http://www.w3.org/TR/dd-structures/
Editor:
José Manuel Cantera Fonseca, Telefónica I+D

Abstract

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.

Status of this Document

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/.

Publication as a Working Draft does not imply endorsement by 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 is a First Public Working Draft of a Working Group Note, 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 [email protected]. 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. The group does not expect this document to become a W3C Recommendation. 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.

Table of Contents

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

Appendices

A References
B Acknowledgements


1 Introduction

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.

Editorial Note : This Working Draft includes a preliminary, early proposal which it is expected to be taken over and revised by a successor of the DDWG.

2 Device Grouping based on XML

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/ddr-structures namespace.

ElementAttributesMinimal Content Model
deviceStructuresNone(vocabularies)?, groups
vocabulariesNone(vocabulary)+
vocabularyiri, nsPrefixEMPTY
groupsNonegroup+
groupidexpression
expressionNonePCDATA (See syntax)

2.1 The deviceStructures element

It is the element that serves as root of the XML document

2.2 The vocabularies element

This element is the parent element for all the vocabulary declarations in the XML document.

2.3 The vocabulary element

The purpose of this element is the declaration of the vocabularies that will be used in the group definitions.

2.3.1 Attributes

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.

2.4 The groups element

This element is the parent element for all the groups defined

2.5 The group element

This is the element used to define a group of devices

2.5.1 Attributes

id

The group's id. This attribute is mandatory. This is the identifier that will be used later by the programmer in the code to ckeck if a device belongs to such group. Group identifiers must be unique and are case sensitive.

2.6 The expression element

This element includes the boolean expression that defines a group.

2.6.1 Expression Syntax

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):

Grammar for group expressions
[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.

3 Extended Simple API

This note proposes two extensions to the DDR Simple API

3.1 Initialization

At initialization time the user of the API need to pass one or more XML files with the group definitions to be used.

3.2 Query Methods

public boolean belongsTo(Evidence evidence,String group);

Returns true if a device belongs to a group

4 Example

4.1 XML group definitions file

					
<deviceStructures xmlns="http://www.w3.org/2008/05/ddr-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>
					
				

4.2 Java Code

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
}

A References

DDR-Simple-API
Device Description Repository Simple API, Jo Rabin, José Manuel Cantera Fonseca, Rotan Hanrahan, Ignacio Marín (eds.), W3C Working Draft, 4 April 2008 (See http://www.w3.org/TR/DDR-Simple-API)
Java
The Java Language Specification, Third Edition (See http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html)

B Acknowledgements

The editor of the document acknowledge significant written contributions coming from: