Copyright © 2008 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
Web content delivered to a mobile context usually benefits from being tailored to take into account a range of factors such as device form factor, input capabilities, browser markup language support and image format support. Data about such information is stored in proprietary databases called "Device Description Repositories" (DDR).
This document describes a simple API for access to DDRs, in order to ease and promote the development of such adaptive Delivery Context aware Web content.
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 Recommendation.
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@w3.org. This list is archived at http://lists.w3.org/Archives/Public/public-ddwg/.
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
1.1 Background to the need for Device Description Repositories
1.2 Development of the Simple API Recommendation
1.3 Scope
2 Reading the Recommendation
2.1 Normative and Informative Parts
2.2 Normative Language for Conformance Requirements
2.3 Language Bindings
3 Interfaces
3.1 Supporting Interfaces
3.1.1 Evidence
3.1.1.1 Methods
3.1.2 PropertyName
3.1.2.1 Methods
3.1.3 PropertyRef
3.1.3.1 Constants
3.1.3.2 Methods
3.1.4 PropertyValue
3.1.4.1 Methods
3.1.5 SimplePropertyValues
3.1.5.1 Methods
3.2 Service Interface
3.2.1 Query Methods
3.2.1.1 Return Known Values
3.2.1.2 Return the Values of a Specific List
3.2.1.3 Return the Value of a Single Property
3.2.2 Factory Methods
3.2.2.1 Create Evidence
3.2.2.2 Create PropertyName
3.2.2.3 Create PropertyRef
3.2.3 Information Methods
3.2.3.1 Get Version Information
3.2.3.2 List Available Properties
3.2.4 Initialization
3.3 Exceptions
3.4 Instantiation
4 Vocabularies
5 Conformance
5.1 General Conformance Requirements
5.2 Conformance Requirements (Languages where there is a Normative Binding)
5.3 Conformance Requirements (Languages where there is no Normative Binding)
A IDL Definitions for Simple API
B Java Bindings
B.1 org.w3c.ddr.simple.Evidence
B.2 org.w3c.ddr.simple.PropertyName
B.3 org.w3c.ddr.simple.PropertyRef
B.4 org.w3c.ddr.simple.PropertyValue
B.5 org.w3c.ddr.simple.PropertyValues
B.6 org.w3c.ddr.simple.Service
B.7 org.w3c.ddr.simple.ServiceFactory
B.8 Exceptions
C WSDL Language Binding
D Binding rules for mapping APIs to any programming language
E Normative References
F Informative Use Case: To Be defined (Non-Normative)
G Informative References (Non-Normative)
H Acknowledgements (Non-Normative)
This section is informative.
The need for Device Descriptions (information about the properties of various aspects of the Delivery Context [definition]) is not confined to the mobile Delivery Context. It has been common, for some time, to use the technique of "browser sniffing" to determine possibly small but important differences between various desktop Web browsers and adapt content to accommodate those differences.
The number of different properties that affect the usability of the resulting content for the desktop Delivery Context is limited, when compared with the number of different properties of the mobile Delivery Context that affect usability of content. Examples of such properties include screen dimensions, input methods, memory and CPU constraints, as well as differences in implementation and support between Web browsers which typically vary by many factors including markup languages supported and image formats supported.
Historically, it has been difficult or impossible to upgrade Web browser software on mobile devices or to add support for features not present in the Web browser originally shipped with the device. This leads to a very wide variation not only of hardware related features but also of features determined by software and firmware. As a result of this, although the need for content adaptation is a general requirement of the Web as a whole, the need for a more systematic approach is seen as being most urgent in the mobile Delivery Context.
As a result, Device Description Repositories (DDRs) have become the sine qua non of development of content targeted at the mobile Delivery Context. A number of proprietary implementations exist, each with its own API and method of describing the properties of the Delivery Context.
The Device Descriptions Working Group (DDWG), a Working Group of the W3C Mobile Web Initiative, was chartered to create a single API though which property values can be retrieved, and a "core" vocabulary [Core Vocabulary] that identifies a small number of such properties.
Editorial Note Rev 1f (JR): Would this section better be placed into a note?
By charter, the DDWG's work was limited to providing an API into a DDR, and to consider only those applications of DDRs that relate to the delivery of Web content to mobile devices.
It was recognised at the time of creation of the charter that there are many other similar use cases, including delivery of non Web content (such as MMS) to mobile devices, as well as delivery of Web content to some types of non mobile devices which may share some of restrictions and wide variations of mobile devices.
It was also recognized that by their very nature, DDRs are limited to describing the values of properties of devices that can be known "a priori". For example, while it may be known that the screen size of a particular device is a certain number of pixels, and while it may also be known that the screen orientation can change from landscape to portrait, it cannot be known a priori what the orientation is at any particular moment.
In the course of the work of the DDWG it became clear that having an API that revealed only the a properties of a particular device that can be known a priori, and a potentially different api to reveal those that can not, would entail usability difficulties for creators of software that uses API. For instance, in the example above relating to screen orientation use of a DDR API would reveal the screen orientation for some set of devices, but for other devices leave the need for further, possibly unrelated, API calls to determine the actual screen orientation. It was felt that such a situation would not serve the community of software developers well.
Unfortunately, categorization of properties into classes of "can not be known a priori" (sometimes called dynamic properties) and "can be known a priori" (sometimes called static properties) turns out to be fraught with difficulties, leaving most properties in the category of "can not be known a priori on some set of devices".
Additionally, as work progressed, the DDWG gained an increasing understanding that properties refer in some cases to the Delivery Context as a whole, and in other cases to specific constituent components of the Delivery Context. For example, screen width and height are often considered to be properties of the device hardware, but more usefully to the developer, they might be considered to represent the size of the canvas when operating system and browser chrome, together with scroll bars are taken into account. In other cases, for example, the properties Vendor, Model and Version, each constituent component of the delivery context has a separate and discrete identity, so it is unhelpful to regard these properties as being a superposition of the contributions of the various individual components.
Moreover, it is possible that more than one component of the same type may be present in the delivery context. The type of the component was described by the DDWG as an "aspect" of the Delivery Context, and as work on the API progressed it became clear that to provide a complete API that allows both the identification of components present in a Delivery Context and also allows the querying of aspects or specific components of the Delivery Context would be a very significant task, well beyond the scope and charter of the DDWG. Such an API would not be limited to mobile Delivery Contexts and would not be limited to determining a priori information.
The DDWG, recognizing the urgent need for an API to ease and promote the development of adaptive context aware content - specifically mobile Web content - decided to create a "simple" API that fulfils the majority of needs of the "Run Time" use case. It decided also to documenting its findings to contribute to a possible future activity in a Working Group chartered to consider uses cases that go beyond the limitations of mobile repository derived information.
Various use cases for DDRs are detailed in [Requirements]. In summary, the uses fall into two main classes: design time and run time. The design time use case relates to the activities of the planning, UI prototyping, market research and so on for mobile Web applications. These are collectively also referred to as cataloging functions. By contrast, the run time use case represents the determining of the actual values of properties that are relevant to a particular application for the delivery of Web content.
The W3C DDR Simple API supports only the run-time use case. It provides read-only functionality to allow an adapting application to provide evidence in the form of HTTP headers that identifies the Delivery Context (DC) and allows it query the DDR for property values of aspects of the DC identified. In addition, it provides access to basic catalog information that allows it to find out about which properties are supported.
The run-time use case consists, in general, of two logically (though not necessarily in practice) distinct activities: Device Recognition and Property Value Retrieval. The simple API does not expose these two activities as distinct to the user of the API.
The types of components that compose a specific Delivery Context (its aspects) are in general many and various. Different vocabularies (sets of properties) recognize different aspects of the delivery context that are "essential" to implementing adaptive mobile content. For example, the Core Vocabulary [Core Vocabulary] recognises the aspects of "device" and "Web browser". Other aspects of the Delivery Context may be supported other vocabularies.
There are an indefinite number of possible properties descriptive of the Delivery Context. The simple API does not define any properties nor mandate the use of any particular vocabulary of such properties. The DDWG strongly recommends that its Core Vocabulary is supported by all DDRs. The requirements of vocabularies supported by the DDR Simple API are documented in 4 Vocabularies.
This Recommendation provides a normative definition of the interface based on OMG IDL [IDL]. In addition, it provides a normative WSDL [WSDL] and Java [Java] bindings.
This section is normative.
The normative and informative parts of this Recommendation are identified by use of labels within various sections.
Individual conformance requirements or testable statements are identified in this document by the use of specific key words. In particular, the key words must, must not, required, shall, shall not, should, should not, recommended, may, and optional in this Recommendation are to be interpreted as described in [RFC 2119] .
This Recommendation identifies three normative language bindings, IDL, Java and WSDL.
Interfaces are identified in the text in the following ways:
IDL
//IDL Example public Example exampleMethod();
Java
//Java Example public Example exampleMethod();
WSDL
//WSDL Example public Example exampleMethod();
Full bindings are provided for each language as Appendices (see A IDL Definitions for Simple API , B Java Bindings and C WSDL Language Binding).
A number of supporting interfaces are defined for various types of data that are used in the DDR Simple API. They are described in the following sections.
The principal interface of the DDR API, Service
, is defined in 3.2 Service Interface, it is this interface that contains the factory methods for creating instances of the interfaces discussed here.
Evidence is the general term applied to providing information to the DDR to allow it to determine the Delivery Context, when querying property values. In the simple API implementations must support evidence consisting of HTTP Header name and value pairs. Implementations must treat HTTP Header names in a case insensitive manner. HTTP header values may be case sensitive, depending on the header concerned. Other types of evidence may be supported by implementations. They are not defined in this Recommendation.
The name of a property together with its namespace. See 4 Vocabularies for a discussion of properties and namespaces.
The name of a property together with its aspect together with their namespace. See 4 Vocabularies for a discussion of properties, aspects and namespaces.
PropertyValue models the PropertyRef / value pair for the property. Values may be empty, in which case the method exists
returns False
. An attempt to query an empty value causes a PropertyValue
exception as does an attempt to query a value with an incompatible accessor method (string as float, for example). Implementations are not required to carry out type conversion when this is possible (float as string, for example).
Value Retrieval
Java
public double getDouble() throws ValueException; public long getLong() throws ValueException; public String getString() throws ValueException; public boolean getBoolean() throws ValueException; public int getInteger() throws ValueException; public String[] getEnumeration() throws ValueException; public float getFloat() throws ValueException;
Existence
Java
public boolean exists();
Property Reference
Java
public PropertyRef getPropertyRef();
Service
InterfaceThe Service
interface is the core of the DDR Simple API. Using methods of Service
the caller supplies Evidence
representing the Delivery Context and an indication of the properties of interest. These methods return PropertyValue
objects which can then be queried to reveal the values of the properties of interest.
The Service
may be instantiated by a supplied factory [@@(q.v.)] class. The class invokes the initialize
method to establish a default vocabulary and to pass implementation specific settings.
All implementations are required to support Evidence
consisting of name/value pairs of HTTP headers.
The methods of the Service
interface fall into the following categories, which are discussed in the subsequent sections:
Query methods return values for properties of the Delivery Context represented by the supplied Evidence
.
The following types of query method exist:
Return all known values
Java
public PropertyValues getPropertyValues(Evidence evidence) throws NameException, SystemException;
Return all known values for the given aspect of the default vocabulary
Java
public PropertyValues getPropertyValues(Evidence evidence, String localAspectName) throws NameException, SystemException;
Return all known values for an aspect of a non-default vocabulary
Java
public PropertyValues getPropertyValues(Evidence evidence, String localAspectName, String aspectIRI) throws NameException, SystemException;
Return values for all the supplied properties, returning null values for those that are not known.
Java
public PropertyValues getPropertyValues(Evidence evidence, PropertyRef[] propertyRefs) throws NameException, SystemException;
Return the value of a specific property
Java
public PropertyValue getPropertyValue(Evidence evidence, PropertyRef propertyRef) throws NameException, SystemException;
Return the value of a specific property in the default aspect of the vocabulary specified by propertyName
Java
public PropertyValue getPropertyValue(Evidence evidence, PropertyName propertyName) throws NameException, SystemException;
Return the value of a specific property in the default aspect of the default vocabulary
Java
public PropertyValue getPropertyValue(Evidence evidence, String localPropertyName) throws NameException, SystemException;
Create Empty Evidence
Java
public Evidence newHTTPEvidence();
Create Evidence from Map
Java
public Evidence newHTTPEvidence(Map map);
Create PropertyName using Default Vocabulary
Java
public PropertyName newPropertyName(String propertyName) throws NameException, SystemException;
Create PropertyName from PropertyRef
Java
public PropertyName newPropertyName(PropertyRef propertyRef) throws NameException, SystemException;
Create PropertyRef using Default Vocabulary and Aspect
Java
public PropertyRef newPropertyRef(String localPropertyName) throws NameException, SystemException;
Create PropertyRef from PropertyName in Default Aspect
Java
public PropertyRef newPropertyRef(PropertyName propertyName) throws NameException, SystemException;
Create PropertyRef from PropertyName in Named Aspect
Java
public PropertyRef newPropertyRef(PropertyName propertyName, String localAspectName) throws NameException, SystemException;
This needs a bit of cleaning up
The DDR Simple API defines a normative factory class, which instantiates Service
with the supplied default namespace and configuration.
Java
public class ServiceFactory { public static Service newService(String clazz, String defaultVocabulary, Properties configuration) throws SystemException, NameException { Service theService = null; try { // Instantiation theService = (Service) Class.forName(clazz).newInstance(); // Initialization theService.initialize(defaultVocabulary, configuration); } catch (Throwable thr) { // TODO: Capture the exceptions properly throw new SystemException(SystemException.INITIALIZATION, thr); } return theService; } public static Service newService(String defaultVocabulary, Properties configuration) throws SystemException, NameException { return null; }
This section is normative.
A vocabulary is a set of properties which together provide information about aspects of the delivery context. From the point of view of this recommendation, a vocabulary defines the relationship between properties and the aspects they refer to.
Vocabularies have a namespace which governs both property names and aspect names. This API does not require that aspect names and property names are distinct from each other, though for the sake of clarity to human readers this is @@probably a good idea.
Property and aspect names must conform to the syntax defined in "Namespaces in XML" [XML Namespaces]. The value "__NULL" is reserved as the null aspect name.
Editorial Note Rev 1f (Jo): Need to define what types vocabs can have
Vocabularies also define the data types of their constituent property values. The allowable dat types are: Unicode String, Integer, Boolean ... [@@to be confirmed] [@@ all with thier meaning defined as in XMLSchema??]
The DDWG has published a suggested "core" vocabulary for essential properties for Web content adaptation [Core Vocabulary]. It is anticipated that implementations will extend the core vocabulary by using properties defined in different name spaces.
[@@Also need to check that the Core Vocab note makes it clear that extensions require that a new namespace is defined.]
This section is normative.
A conforming implementation of this Recommendation must implement all the normative sections of this document outside the appendices and must implement a binding conformant with one of the following sections.
This appendix contains the complete normative OMG IDL [IDL] definitions for DDR-API
Editorial Note Version 1f (JR): need new version
IDL
tbd
Java bindings are normative?
The code can be browsed at http://www.w3.org/2005/MWI/DDWG/drafts/api/simple/java/org/w3c/ddr/simple/
Java
package org.w3c.ddr.simple; /** * An interface representing evidence that is to be supplied to getPropertyValue * or getPropertyValues methods of {@link Service} * * @author jo * */ public interface Evidence { /** * Add a key / value pair * @param key The key * @param value The value */ public void put(String key, String value); /** * True if a key exists * @param key * @return */ public Boolean exists(String key); /** * Get the value corresponding to the key * @param key * @return */ public String getValue(String key); }
Java
package org.w3c.ddr.simple; public interface PropertyName { /** * The name of the property * * @return */ public String getPropertyName(); /** * The namespace of the property * * @return * */ //TODO Worry about whether an IRI class is needed public String getNamespace(); }
Java
package org.w3c.ddr.simple; /** * Represents a property / aspect combination * * @author jo * * */ public interface PropertyRef { public static final String NULL_ASPECT = "__NULL"; /** * The name of the property * * @return */ public String getPropertyName(); /** * The name of the aspect * * @return */ public String getAspectName(); /** * The namespace of the property and aspect * * @return * */ //TODO Worry about whether an IRI class is needed public String getNamespace(); }
Java
package org.w3c.ddr.simple; import org.w3c.ddr.simple.exception.ValueException; /** * Represents the value of a property * * @author jmcf * */ public interface PropertyValue { /** * * Returns the value as double in the default units of the property * * If the value cannot be represented as a double an exception will be * thrown * * */ public double getDouble() throws ValueException; /** * * Returns the value as a long in the default units of the property * * An exception will be thrown if the value cannot be represented as a long * * @return * @throws ValueException */ public long getLong() throws ValueException; /** * * Returns the value of the property as a String * * This method will return * * @return */ public String getString() throws ValueException; /** * Returns the actual value as a boolean * * If the value cannot be represented as a boolean an exception will be * thrown * * @return * @throws DDRException */ public boolean getBoolean() throws ValueException; /** * * Returns the value as an integer in the default units of the property * * An exception will be thrown if the value cannot be represented as an * Integer * * @return * @throws DDRException */ public int getInteger() throws ValueException; /** * * Returns the value as an enumeration * * If the value cannot be represented as an enumeration an exception will be * thrown * * * @return * @throws DDRException */ public String[] getEnumeration() throws ValueException; /** * * Returns the value in the specified unit as a float * * If the value cannot be represented as a float an exception will be thrown * * * */ public float getFloat() throws ValueException; /** * @return */ public PropertyRef getPropertyRef(); /** * @return */ public boolean exists(); }
Java
package org.w3c.ddr.simple; import org.w3c.ddr.simple.exception.NameException; import org.w3c.ddr.simple.exception.SystemException; public interface PropertyValues { public PropertyValue[] getAll() throws SystemException; public PropertyValue getValue(PropertyRef prop) throws SystemException, NameException; }
Java
package org.w3c.ddr.simple; import java.util.Map; import java.util.Properties; import org.w3c.ddr.simple.exception.NameException; import org.w3c.ddr.simple.exception.SystemException; public interface Service { /** * Called by {@link ServiceFactory} to initialize the API following * construction * * @param defaultVocabularyIRI * the IRI of the default vocabulary namespace * @param props * Implementation dependent properties * @throws SystemException */ public void initialize(String defaultVocabularyIRI, Properties props) throws SystemException; /** * * @return A string indicating the revision level of the API */ public String getAPIVersion(); /** * * @return A String indicating the revision level of the data */ public String getDataVersion(); /** * List all the PropertyRefs the API knows about * * @return * @throws SystemException */ public PropertyRef[] listPropertyRefs() throws SystemException; public PropertyValue getPropertyValue(Evidence evidence, PropertyRef propertyRef) throws NameException, SystemException; public PropertyValue getPropertyValue(Evidence evidence, PropertyName propertyName) throws NameException, SystemException; public PropertyValue getPropertyValue(Evidence evidence, String localPropertyName) throws NameException, SystemException; public PropertyValues getPropertyValues(Evidence evidence) throws SystemException; public PropertyValues getPropertyValues(Evidence evidence, PropertyRef[] propertyRefs) throws NameException, SystemException; public PropertyValues getPropertyValues(Evidence evidence, String localAspectName) throws NameException, SystemException; public PropertyValues getPropertyValues(Evidence evidence, String localAspectName, String aspectIRI) throws NameException, SystemException; public PropertyName newPropertyName(String propertyName) throws NameException, SystemException; public PropertyName newPropertyName(PropertyRef propertyRef) throws NameException, SystemException; public PropertyRef newPropertyRef(String localPropertyName) throws NameException, SystemException; public PropertyRef newPropertyRef(PropertyName propertyName) throws NameException, SystemException; public PropertyRef newPropertyRef(PropertyName propertyName, String localAspectName) throws NameException, SystemException; /** * Create a Evidence using the Map consisting of HTTP Header Names and * Values * * @param map * @return */ public Evidence newHTTPEvidence(); public Evidence newHTTPEvidence(Map map); }
Java
package org.w3c.ddr.simple; import java.util.Properties; import org.w3c.ddr.simple.exception.NameException; import org.w3c.ddr.simple.exception.SystemException; public class ServiceFactory { public static Service newService(String clazz, String defaultVocabulary, Properties configuration) throws SystemException, NameException { Service theService = null; try { // Instantiation theService = (Service) Class.forName(clazz).newInstance(); // Initialization theService.initialize(defaultVocabulary, configuration); } catch (Throwable thr) { // TODO: Capture the exceptions properly throw new SystemException(SystemException.INITIALIZATION, thr); } return theService; } public static Service newService(String defaultVocabulary, Properties configuration) throws SystemException, NameException { return null; } }
This section is normative. It describes a WSDL [WSDL] language binding for DDR-API.
WSDL
tbd
This section is normative
Editorial Note Rev 1f (Jo): I am not convinced this is needed.
This section is informative. It provides an illustration of how the DDR-API could operate.