W3C

Content Selection for Device Independence (DISelect) 1.0

W3C Working Draft 02 May 2005

This version:
http://www.w3.org/TR/2005/WD-cselection-20050502/
Latest version:
http://www.w3.org/TR/cselection/
Previous version:
http://www.w3.org/TR/2004/WD-cselection-20040611/
Editors:
Rhys Lewis, Volantis Systems Ltd. <rhys@volantis.com>
Roland Merrick, IBM <roland_merrick@uk.ibm.com>

Abstract

This document specifies a syntax and processing model for general purpose content selection or filtering. Selection involves conditional processing of various parts of an XML information set according to the results of the evaluation of expressions. Using this mechanism some parts of the information set can be selected for further processing and others can be suppressed. The specification of the parts of the infoset affected and the expressions that govern processing is by means of XML-friendly syntax. This includes elements, attributes and XPath expressions. This document specifies how these components work together to provide general purpose selection.

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

This is a W3C Last Call Working Draft of the Content Selection for Device Independence (DISelect) specification, for review by W3C members and other interested parties. The Last Call review period ends on 03 June 2005 at 2359Z. Please send review comments before the end of the review period to public-diselect-editors@w3.org. This list is archived at http://lists.w3.org/Archives/Public/public-diselect-editors/.

Following completion of Last Call, the Device Independence Working Group plan to produce formal responses to all comments received by the Working Group and then advance the specification to a Candidate Recommendation.

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 document is published as part of the W3C Device Independence Activityby the Device Independence Working Group (Member Only Link). It is a deliverable as defined in the Charter of that group.

This document was produced under the 5 February 2004 W3C Patent Policy. The Working Group maintains a public list of patent disclosures relevant to this document; that page also includes instructions for disclosing [and excluding] a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) with respect to this specification should disclose the information in accordance with section 6 of the W3C Patent Policy.

Table of Contents

1 Introduction
    1.1 Towards a Device Independent Markup Language Profile
    1.2 Reading the Specification
        1.2.1 Conformance Information for DISelect
            1.2.1.1 Normative and Informative Parts
            1.2.1.2 Normative Language for Conformance Requirements
    1.3 Documentation Conventions
2 Document Structure
    2.1 The Namespaces
    2.2 The Selection Module
3 Processing Model
    3.1 Events Overview
    3.2 Events that Affect Processing
        3.2.1 The diselect-reprocess Event
    3.3 Events in Response to Errors
        3.3.1 The diselect-invalid-type-error Event
        3.3.2 The diselect-redeclaration-error Event
        3.3.3 The diselect-declaration-exception Event
        3.3.4 The diselect-compute-exception Event
4 Attributes for Conditional Processing
    4.1 Overview
    4.2 The expr Attribute
    4.3 The selid and selidName Attributes
    4.4 Using the Attributes
5 Elements for Conditional Processing
    5.1 Overview
    5.2 The if Element
        5.2.1 Attributes
    5.3 The select Element
        5.3.1 Attributes
        5.3.2 Processing
    5.4 The when Element
        5.4.1 Attributes
    5.5 The otherwise Element
    5.6 The options Element
        5.6.1 Attributes
    5.7 The idreplace Element
        5.7.1 Attributes
    5.8 The process Element
        5.8.1 Attributes
    5.9 The required Element
        5.9.1 Attributes
    5.10 Using the Elements
6 Variables
    6.1 The variable Element
        6.1.1 Attributes
        6.1.2 Declaring a Variable
        6.1.3 Referencing an Existing Variable Using the variable Element
        6.1.4 References to Variables in XPath Expressions
        6.1.5 Scope of Variables and Nesting
        6.1.6 Types
            6.1.6.1 Type Conversion
    6.2 The value Element
        6.2.1 Attributes
    6.3 Using Variables
7 Attribute Value Templates
    7.1 Using Attribute Value Templates
8 Expressions in DISelect
    8.1 Formal Grammar
9 Starter Set XPath Functions for Delivery Context Access
    9.1 Default Values
    9.2 The di-cssmq-width function
    9.3 The di-cssmq-height function
    9.4 The di-cssmq-device-width function
    9.5 The di-cssmq-device-height function
    9.6 The di-cssmq-device-aspect-ratio function
    9.7 The di-cssmq-device-aspect-ratio-width function
    9.8 The di-cssmq-device-aspect-ratio-height function
    9.9 The di-cssmq-color function
    9.10 The di-cssmq-color-index function
    9.11 The di-cssmq-monochrome function
    9.12 The di-cssmq-resolution function
    9.13 The di-cssmq-scan function
    9.14 The di-cssmq-grid function
    9.15 Units
        9.15.1 Length Units
        9.15.2 Resolution Units

Appendices

A Schema
B References
    B.1 Normative References
    B.2 Informative References
C Changelog (Non-Normative)
    C.1 Changes in this Version
D Acknowledgements (Non-Normative)


1 Introduction

1.1 Towards a Device Independent Markup Language Profile

This specification represents one part of the approach being developed within DIWG for the provision of a markup language that supports creation of web sites that can be used from a wide variety of devices with a wide variety of characteristics.

The overall approach being taken by DIWG is based on the development of a device independent profile for XHTML. The profile will be based on XHTML Version 2 [XHTML 2], XForms [XForms] and current and forthcoming versions of CSS [CSS]. DIWG is developing additional modules that can be added to this combination of specifications to complete the profile.

This specification describes the module that provides selection between different versions of materials. This module is designed to be used within other markup languages, and in particular, within the device independent profile for XHTML being developed by DIWG. The term host language is used in this document to indicate the language within which DISelect is being used.

In its paper on Authoring Challenges [Authoring Challenges], DIWG identified a series of challenges faced by authors trying to create materials that could be used on a wide variety of devices with very different characteristics. One common theme emerging from this work was the need to support authors in the specification of variabilityin the materials they produce.

In its paper on Device Independence Principles [DI Principles], DIWG pointed out that the process by which authored materials are adapted for use on particular devices may take place at any point between the source of the material and the device itself.

The ability to select between different verisons of material provides one important mechanism by which authors can support variability. The mechanism by which a particular version is chosen from those available, during adaptation should not be excessive in its processing demands, since it may need to be performed on a device with limited capacity.

Some user agents provide programming capability that can be exploited by authors to achieve results similar to those described in this specification. For example, [ECMAScript] is available in some browsers. Such facilities are, of course, very powerful, and allow dynamic modification of and interaction with the page during the user interaction. However, they are not universally available. In addition, the intent of the author is embodied within the program code rather than being declared within markup. This may cause difficulties in interpretation for assistive technologies, for example.

This specification provides a simple mechanism for the selection of the content that is to be expressed when adaptation takes place. It does not attempt to provide the dynamic modification associated with browser programming, embodied in languages such as [ECMAScript], nor does it attempt to provide the comprehensive transformation capabilities of [XSLT]. Rather, it provides capabilities that could be implemented using those mechanisms, but in a way that can requires only modest capability from the processors involved.

1.2 Reading the Specification

1.2.1 Conformance Information for DISelect

1.2.1.1 Normative and Informative Parts

The normative and informative parts of this specification are identified by use of labels within various sections. Generally, everything in the specification is considered to be normative, apart from the examples.

1.2.1.2 Normative Language for Conformance Requirements

Individual conformance requirements or testable statements are identified in the DISelect specification 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 optionalin this specification are to be interpreted as described in [IETF RFC 2119].

1.3 Documentation Conventions

The following namespace prefixes and corresponding namespace identifiers are used in this document:

sel:

The DISelect namespace described in section 2.1 The Namespaces.

dcn:

The Delivery Context namespace described in section 2.1 The Namespaces.

In the examples, the default namespace, with no prefix, is used to indicate the host language within which the content selection markup is being used. The examples assume that the host language is XHTML Version 2 [XHTML 2].

The XML representations of various elements within DISelect are presented using the syntax for Abstract Modules in XHTML Modularization [XHTML Modularization]

Expressions in the examples used in this document are based on [XPath 1.0]. This syntax requires that specific characters be escaped appropriately for use within XML processors. This quoting is used explicitly throughout the document.

2 Document Structure

2.1 The Namespaces

The DISelect namespace has the URI: http://www.w3.org/2004/06/diselect. The Delivery Context namespace has the URI: http://www.w3.org/2004/06/dc.

XML Processors must use the XML namespaces mechanism [XML Names] to recognize elements and attributes from this namespace

2.2 The Selection Module

Elements and attributes in the content selection module
Elements Attributes Minimal Content Model
ANY ##other expr
ANY #other selid
ANY #other selidName
if expr ((ANY ##other) | if | select)*
select expr, precept when* otherwise?
when expr ((ANY ##other) | if | select)*
otherwise ((ANY ##other) | if | select)*
variable name, ref, value EMPTY
value expr
options expr required* | process | idreplace
idreplace name EMPTY
process type EMPTY
required functions EMPTY

The selection module consists of a set of elements and associated attributes that allow authors to specify how content will be selected for use in different delivery contexts.

The if and select elements provide mechanisms for choosing whether or not to use particular parts of the content. Their associated attributes and sub-elements provide the means to control how the alternatives are defined and how the decisions are made.

Section 4 Attributes for Conditional Processing describes how the attributes are used within a host markup language. Section 5 Elements for Conditional Processing describes the markup elements themselves. Section 8 Expressions in DISelect describes the expressions used within DISelect to control the decisions about which content is used. Section 6 Variables describes variables that can be used to simplify expressions. Finally, Section 9 Starter Set XPath Functions for Delivery Context Access describes a starter set of functions used within expressions to access information from the delivery context.

3 Processing Model

This section is normative.

Selection, as defined in this document, is a specific type of transformation applied to an XML information set [XML Infoset]. The input for the selection transformation is referred to as the source infoset. The result of the transformation is referred to as the result infoset.

The source infoset includes elements and attributes from the DISelect namespace. These attributes and elements control whether or not certain parts of the source infoset are expressed in the result infoset. The details of how this occurs are described in 4 Attributes for Conditional Processing.

The elements and attributes from the DISelect namespace which are present in the source infoset do not appear in the result infoset.

3.1 Events Overview

DISelect uses the events system defined in [DOM2 Events] and [XML Events]. These event models specify an event capture flow that includes:

Capture Phase

Processing where the event flows down the DOM tree towards its target element. In this phase, appropriately registered event handlers are notified of the event and may perform processing based on it.

Arrival at Target

When the event arrives at its target element, event handlers registered there are notified of the event and may perform processing based on it.

Bubbling Phase

Processing in which the event flows back up the DOM tree towards its root. In this phase, appropriately registered event handlers are notified o the event an may perform processing based on it.

The following sections define specific events associated with DISelect. In each case, the target element is defined together with information about whether the event bubbles and whether or not the default action can be cancelled.

3.2 Events that Affect Processing

In some environments, for example where DISelect is used in markup that resides on a client device, it is desirable to allow content selection to respond dynamically to events. For example, it might be advantageous to allow changes in the delivery context, as experienced by a device, to influence adaptation occurring at the device.

To support this usage, a DISelect processor needs to re-process the source infoset and produce a new and possibly different result infoset. Re-processing occurs in response to the diselect-reprocess event.

3.2.1 The diselect-reprocess Event

When this event is raised, the DISelect processor re-processes the source infoset to create a new version of the result infoset.

Cancelable? Bubbles? Target Element Default Action
No Yes The process element with most global scope in the document The DISelect processor behaves according to the settings specified in any process elements in the source infoset.

This event can be raised only by mechanisms external to DISelect. For example, a user agent that includes a DISelect processor might raise the event in response to a change in the delivery context that it experiences. After the new result infoset is created, the user agent would typically regenerate the user experience.

Support for this event is optional in the following sense. DISelect processors that execute in environments that cannot generate this event do not need to support it. For example, a DISelect processor executing within a system performing server-side adaptation typically cannot respond to changes in delivery context that occur while it is processing a particular request. Such processors cannot encounter this event and do not need to support it.

Authors have a degree of control over whether a DISelect processor reprocesses a source infoset in response to this event. The process element allows an author to prevent reprocessing even when a processor supports it.

3.3 Events in Response to Errors

During transformation, certain situations may occur that cause events to be raised. These situations represent errors that have been detected by the DISelect processor. DISelect does not contain any facilities by which events can be detected and processed other than by the processor.

Error indications happen as a result of unusual conditions in the DISelect Processor. There are two types of error indication.

Fatal Error

Fatal errors cause the DISelect processor to halt. The names of these errors bear the suffix exception.

Non-fatal Error

These errors are raised for notification. They do not cause the DISelect processor to halt. They bear the suffix error. It is permissible for the DISelect Processor to perform default handling for any of the events of this type. For example, a DISelect processor might choose to log error messages to a file.

3.3.1 The diselect-invalid-type-error Event

This event is raised when the DISelect processor detects a type mismatch. For example, this event will be raised if an attempt is made to assign a value to a variable which cannot be converted to the variable's type.

Cancelable? Bubbles? Target Element Default Action
No Yes The element in which the type mismatch occurred The DISelect processor ignores the assignment.

3.3.2 The diselect-redeclaration-error Event

This event is raised when an attempt is made to declare a variable that is already in existence. It is a non fatal error.

Cancelable? Bubbles? Target Element Default Action
No Yes The element in which the declaration occurred The DISelect processor ignores the redeclaration.

3.3.3 The diselect-declaration-exception Event

This event is raised when an attempt is made to declare a variable but the declaration is invalid. A declaration is invalid, for example, if no value initial value is specified for the variable. It is a fatal error.

Cancelable? Bubbles? Target Element Default Action
No Yes The element in which the declaration occurred The DISelect processor halts.

3.3.4 The diselect-compute-exception Event

This event is raised when an unrecoverable error occurs during the evaluation of an XPath expression. It is raised, for example, if an XPath function required for evaluation of an expression is not available to the processor. It is a fatal error.

Cancelable? Bubbles? Target Element Default Action
No Yes The element in which the compute exception occurred The DISelect processor halts.

4 Attributes for Conditional Processing

This section is normative.

4.1 Overview

DISelect provides two attributes that can be used with elements of the host language. This section describes those attributes. One attribute, expr, simplifies the specification of selection under certain circumstances. The other attribute, selid, provides a mechanism for avoiding problems associated with duplication of values of host language attributes that represent unique identifiers.

When used within a host language element, the DISelect attributes need to be appropriately qualified to indicate that they are within the content selection namespace.

4.2 The expr Attribute

The expr attribute is useful for decisions that affect small amounts of content. If a decision applies to a significant amount of content or relates to a number of different versions, the alternative, element-based forms are usually more convenient. These are described in Elements for Conditional Processing.

The expr optional attribute is used within elements of the host language. It defines an expression used to determine whether or not the host language element appears in the output infoset. These expressions are described in 8 Expressions in DISelect.

The value of the expr attribute mustmatch the XPath production DISelectExpr.

The DISelect processor evaluates the expression. If the result has a boolean value of true, the element and its entire body content appears in the result infoset. If it has a value of false, the element and its entire body content is omitted from the result infoset. The attribute itself does not appear in the result infoset.

The default value of this attribute is true. Consequently, if the attribute is omitted, a processor must treat the associated element as if the value were true and include it in the output infoset.

Section 4.4 Using the Attributes illustrates the use of the expr attribute.

4.3 The selid and selidName Attributes

The notion of unique identifiers that can be associated with particular elements in markup languages is common, if not universal. Using them allows particular instances to be identified so that, for example, links can be created or particular styling can be specified.

The uniqueness of these identifiers usually forms part of the validity constraints associated with the host language. The presence of multiple elements with the same identifier violates the constraints and makes the associated document invalid. This is a potential issue when the host language is combined with a selection mechanism, such as the one detailed here. An author may wish to provide alternative versions of particular elements to be used under different circumstances. Both versions may need to carry the same identifier. Consequently, although the document resulting from processing the selection markup will be valid, the document containing the selection markup is not. The selid and selidNameattributes provide a solution for this problem.

The selid optional attribute can be used with elements of the host language. It defines the value that will be used for the host language identifier that will be associated with the host language element on which it is used.

Any language profile which includes DISelect mustspecify the default name of the attribute generated from the selidattribute by default. Typically this will be the name of the unique identifier for the host language.

Sometimes it may be necessary to override the default name provided by the language profile that uses DISelect. This might be the case where some material from another namespace is being incorporated or included. The selidNameattribute provides a means to specify the name of the attribute to be generated when such an override is required.

In summary, during processing, the DISelect processor replaces the selidattribute with a host language attribute with the same value as that of the selidattribute. If no selidNameattribute is specified, the generated attribute has the name defined as the default for the host language. If a selidName attribute is specified, the generated attribute has a name which is the value of that attribute.

Section 4.4 Using the Attributes illustrates the use of the expr attribute.

4.4 Using the Attributes

The examples in this section are informative.

The following example illustrates suppression of the display of an image if the usable width of the display on a device is too small. The first and third paragraphs containing the text are always presented. However, the second paragraph containing the image is shown only if the di-cssmq-width function indicates that the usable width of the device display is more than 200 pixels. If the second paragraph is shown, the object element will carry a generated id attribute with a value of artimg42.

<p>The flooding was quite extensive.</p>
<p sel:expr="di-cssmq-width('px') &gt; 200">
    <object src="image1" sel:selid="artimg42"/>
</p>
<p>Many people were evacuated from their homes.</p>

The conditional expressionsused within the exprattribute can contain multiple terms that relate to different characteristics from the delivery context. So, for example, if the image should only be shown on devices with color displays wider than 200 pixels, the following markup might be used.

<p>The flooding was quite extensive.</p>
<p sel:expr="di-cssmq-width('px') &gt; 200 &amp; di-cssmq-color() &gt; 0">
    <object src="image1" sel:selid="artimg42" sel:selidName="myns:myid"/>
</p>
<p>Many people were evacuated from their homes.</p>

In this version of the example, the value of the exprattribute is true only if the di-cssmq-width function indicates that the usable width of the device is more than 200 pixels and that the di-cssmq-color function indicates that the display supports color.

In addition, in this second example, if the second paragraph is shown, the object element will carry a generated myns:myid attribute with a value of artimg42. In this case, the selid attribute specifies the value of the generated attibute and the selidName attribute specifies its name.

Notice that in these examples, the attributes relating to conditional selection are qualified to indicate that they are from that particular namespace.

5 Elements for Conditional Processing

This section is normative.

5.1 Overview

DISelect defines several elements used for controlling whether or not material appears in the output infoset as a result of processing. It also defines one element used to specify additional capabilities that must be available for use.

5.2 The if Element

This element defines a set of material that is to be included in the output infoset if the associated expression has the appropriate value. This element provides an alternative to use of the expr attribute in the elements of the host language. It is particularly useful when a specific condition applies to several elements of the host language. In addition, the if element allows control to be applied to an arbitrary fragment of the host language that does not itself have a single root element.

Note that there is no else element. Instead, the select element and its children, provide the mechanism for choosing between alternative versions of material.

5.2.1 Attributes

expr

This mandatory attribute defines an expression used in determining whether or not the body content of the element appears in the output infoset. If the expression evaluates to a boolean value of true, the body content of the if element appears in the output infoset. If the expression evaluates to a value of false, the body content of the if element is omitted from the output infoset.

The value of the expr attribute mustmatch the XPath production DISelectExpr.

5.3 The select Element

This element encloses one or more sets of material that are subject to conditional selection. Its body content consists of one or more when elements and an optional otherwise element. Expressions associated with the select and when elements control the conditions under which particular parts of the content are processed.

5.3.1 Attributes

expr

This optional attribute defines an expression used in determining whether or not the entire select element is processed by the DISelect processor. If the expression evaluates to a boolean value of true, the select element is processed with the result that some of the content it contains may appear in the result infoset. If the expression has a value of false, the entire select element is ignored by the DISelect processor.

The value of the expr attribute mustmatch the XPath production DISelectExpr.

precept

This mandatory attribute defines the basic rule applied to matching within the select element.

matchfirst

This is the default value.

When this value is specified, the body content of the first whenelement that has an exprattribute that evaluates to trueappears in the output infoset. The body content of other when elements is ignored, even if their exprattributes evaluate to true. The body content of any otherwiseelement is ignored if any of the when elements has an exprattribute that evaluates to true.

matchevery

When this value is specified, the body content of every when element that has an exprattribute that evaluates to trueappears in the output infoset. The body content of any otherwise element is ignored if any of the when elements has an exprattribute that evaluates to true.

5.3.2 Processing

The whenelements within a selectare processed in document order. This is significant since this order can affect the particular whenelement chosen when the precept attribute has a value of matchfirst. It also affects the order in which material is included in the output infoset when the preceptattribute is set to matcheveryand multiple whenelements have .exprattributes that evaluate to true.

5.4 The when Element

This element defines a set of material that is to be selected for processing if the associated expression has the appropriate value. A single select element may contain multiple when elements.

5.4.1 Attributes

expr

This mandatory attribute defines an expression used in determining whether or not the body content of the element appears in the output infoset. If the expression evaluates to a boolean value of true, the body content of the when element appears in the output infoset. If it evaluates to false, the body content of the when element is omitted from the output infoset. Note, however, that the value of the precept attribute of the containing select element determines overall which when elements are considered for possible selection.

The value of the expr attribute mustmatch the XPath production DISelectExpr.

5.5 The otherwise Element

This element defines a set of material that appears in the output infoset if none of the when elements within the containing select element has an exprattribute that evaluates to true.

5.6 The options Element

This element provides a container for options that relate to the DISelect processor and which apply to some or all of the source infoset. Rules about the scope of the optionselement, the places in which it can be used and whether or not optionselements can be nested mustbe defined by any host language profile that includes DISelect.

5.6.1 Attributes

expr

This optional attribute defines an expression used in determining whether or not the entire options element is processed by the DISelect processor. If the expression evaluates to a boolean value of true, the options element is processed. This results in particular options being established which control subsequent processing by the DISelect processor.

The value of the expr attribute mustmatch the XPath production DISelectExpr.

5.7 The idreplace Element

This element provides a way to specify the name of the unique identification attribute generated from a selid attribute by the DISelect processor. The element appears within an options element.

5.7.1 Attributes

name

This mandatory attribute defines the name of the attribute to be generated from the selid attribute of the markup in the source infoset.

5.8 The process Element

This element provides additional control over the processing carried out by a DISelect processor.

5.8.1 Attributes

type

This optional attribute defines when the source infoset is procesed. It can take one of the following values:

every

This is the default value.

When this value is specified and the processor can reprocess the source infoset, it does so whenever a diselect-reprocess event is raised.

once

When this value is specified, the processor processes the source infoset once only, even if the processor is capable of processing diselect-reprocess events.

5.9 The required Element

This element defines additional resources that are required to enable processing of material that contains DISelect elements and attributes. The DISelect processor verifies that any resources specified using this element are available. If they are not, the processor causes an invalid computation exception to be raised (see 3.3.4 The diselect-compute-exception Event).

A DISelect processor mustverify the availability of the resources defined by this element no later than the point during processing at which it encounters the element in the source infoset. A DISelect processor mayverify resource availability before it encounters the element. For example, the processor may verify the availability of resources at the time the infoset containing the element is loaded. This provides an optimisation by avoiding unnecessary processing that would be rendered invalid by subsequent discovery of missing resources.

The requiredelement can occur any number of times within an options element. The set of resources required by the source infoset is considered to be the union of those defined by all of the required elements in all of the optionselements that are processed by the DISelect processor. It does not, of course, include the resources defined within optionselements that are not processed because of the value of their expr attribute.

5.9.1 Attributes

functions

This optional attribute defines a space-separated list of XPath extension functions (represented by QNames) required for processing.

The document may use additional XPath functions beyond those defined in this specification. The names of any such functions must be declared in this attribute. Such declarations are used by the DISelect processor to check against available functions.

5.10 Using the Elements

The examples in this section are informative.

In this first example, the exprattribute on the ifelement controls the selection. If the display on the device is more than 200 pixels wide, both the image and the paragraph will be included in the output infoset. If the display is not more than 200 pixels wide, they will be omitted.

<sel:if expr="di-cssmq-width
('px') &gt; 200">
  <object src="image1"/>
  <p>Many people had to be evacuated.</p>
</sel:if>  

In the second example, the exprattributes on the whenelements control the selection.

<sel:select>
  <sel:when expr="di-cssmq-width('px') &gt; 200">
    <object sel:selid="pic42" src="image1"/>
  </sel:when>
  <sel:when expr="di-cssmq-color() &gt; 4">
    <object sel:selid="pic42" src="image2"/>
  </sel:when>
  <sel:otherwise>
    <p sel:selid="pic42">Many people had to be evacuated.</p>
  </sel:otherwise>
</sel:select>  

Each whenelement carries an expression in its exprattribute. The selectelement does not have a preceptattribute. As a result, the precept defaults to matchfirst. Consequently, the body content of the first whenelement whose exprattribute evaluates to truewill be included in the output infoset. Based on the expressions in the example, if the usable width of the device, as reported by the di-cssmq-width function, is greater than 200 pixels, image1will be included. If it is not, but if the device supports more than 4 bits per color, as reported by the di-cssmq-color function, image2will be included. If neither of these conditions is true, the body content of the otherwiseelement will appear in the output infoset. In this case it is a paragraph of text.

This example also illustrates use of the selid attribute. The image elements and the paragraph element all carry the same value of pic42 for this attribute. After processing, whichever of the elements appears in the output infoset will carry an id attribute with this value.

<sel:select precept="matchevery">
  <sel:when expr="di-cssmq-width('px') &gt; 200">
    <object src="image1"/>
  </sel:when>
  <sel:when expr="di-cssmq-color() &gt; 4">
    <object src="image2"/>
  </sel:when>
  <sel:otherwise>
    <p>Many people had to be evacuated.</p>
  </sel:otherwise>
</sel:select>  

The third example is a slightly modified version of the second example. The selectelement carries a preceptattribute with a value of matchevery. This change means that the body content of every whenelement whose exprattribute evaluates to trueis included in the output infoset. In this version of the example, if the usable width of the device is greater than 200 pixels and the device supports more than 4 bits per color, both images will be included. With a precept of matchfirst, only image1would have been included. If neither of the conditions is true, the paragraph be included instead of the images.

<sel:options>
  <sel:idreplace name="myns:myid"/>
  <sel:process type="once"/>
  <sel:required functions="myfns:specialFunction1 mynfs:specialFunction2"/>
</sel:options>
...
<sel:select precept="matchfirst">
  <sel:when expr="di-cssmq-width('px') &gt; 200 and "di-cssmq-color() &gt; 4>
    <object src="image1"/>
  </sel:when>
  <sel:when expr="di-cssmq-color() &gt; 4">
    <object src="image2"/>
  </sel:when>
  <sel:otherwise>
    <p>Many people had to be evacuated.</p>
  </sel:otherwise>
</sel:select>  

The final example illustrates the use of slightly more complex expressions within the exprattribute on the whenelements. In this case, the content of the first when element will be selected if the usable width of the device is greater than 200 pixels and the device supports more than 4 bits per color.

This example also illustrates use of the options element. This sets up a number of options associated with processing. It includes an idreplace element that defines the name of the generated unique identifiers as myns:myid. It also specifies that the DISelect processor should process the source infoset only once. It should not process this infoset again, even if adiselect-reprocess event is raised and the processor is capable of processing it. The options element also includes a required element that defines two additional functions needed by this particular source infoset.

6 Variables

DISelect supports the use of variables to help reduce the complexity of expressions and markup. Variables are declared and initialized using markup. Their values can also be modified using markup. Variables can be referenced from within expressions using standard XPath mechanisms.

6.1 The variable Element

The variable element is used to declare a variable and to set its value.

6.1.1 Attributes

name

This attribute specifies the name of the variable. It is used when declaring a new variable.

ref

This attribute specifies the name of the variable. It is used when referring to a variable that has already been declared.

value

This attribute specifies an XPath expression that provides the value to be assigned to the variable.

The value of the value attribute mustmatch the XPath production DISelectExpr.

6.1.2 Declaring a Variable

A variable is declared by using the variable element with its name attribute set to the name of the new variable. Variables mustbe declared before they can be referenced.

The initial value of a variable is used to determine its type. The type of the variable is the type of the result of the expression that provides its initial value.

It is mandatory, to supply an initial value to a variable when declaring it. Initial values are supplied using a suitable expression in the value attribute. If the initial value is omitted from a declaration, an invalid declaration exception is raised (see 3.3.3 The diselect-declaration-exception Event). The DISelect processor halts.

6.1.3 Referencing an Existing Variable Using the variable Element

References to existing variables from markup use the variable element and specifiy the name of the variable through the refattribute. The value of a variable can be altered using this form of reference. Referen

When a variable is updated, the supplied value is converted to the type associated with the variable when it was originally declared. If conversion fails, an invalid type event is raised (see 3.3.1 The diselect-invalid-type-error Event). The DISelect processor continues processing, but the value of the variable remains unchanged.

6.1.4 References to Variables in XPath Expressions

References from XPath expressions use the normal notation. The name of the variable is prefixed with $. Consequently, a variable declared using a variable element with a name attribute of widthis referenced from an XPath expression as $width.

6.1.5 Scope of Variables and Nesting

The declaration of a variable defines its scope. The scope of a variable is from the point at which it is declared to the end of the body content of the element that contains its declaration. Repeated declaration of a variable within the same scope is considered to be a non-terminating error. It causes a redeclarationevent to be raised (see 3.3.2 The diselect-redeclaration-error Event). This is a non-fatal error. The DISelect processor continues processing, but ignores the redeclaration.

A variable can be referenced only from within its scope. An element that references a variable must be within the scope of the variable. An expression that references a variable must be associated with an element that is within the scope of the variable.

If variables with the same name are declared in nested scopes, the inner declaration hidesthe outer declaration for the scope of the inner declaration. References to the variable from within the inner scope apply to the inner declaration.

6.1.6 Types

Variables in DISelect are typed. The following datatypes are recognised by DISelect processors:

string

This is the string data type as defined in [XPath 1.0]

number

This is the number data type as defined in [XPath 1.0]

boolean

This is the boolean data type as defined in [XPath 1.0]

6.1.6.1 Type Conversion

When the value being assigned to a variable differs in type from the type associated with the variable itself, conversion is required. The rules that apply to conversion in DISelect are the same as those described in [XPath 1.0].

If conversion fails, a diselect-invalid-type-error event is raised.

6.2 The value Element

The value element is used to include the value of an expression in the content. The DISelect processor evaluates the expression specified in the element. It places the value of that expression in the result infoset in place of the value element.

6.2.1 Attributes

expr

This mandatory attribute defines the expression that is evaluate to compute the value to be inserted into the result infoset in place of the element.

The value of the expr attribute mustmatch the XPath production DISelectExpr.

6.3 Using Variables

The examples in this section are informative.

<sel:variable name="nColors" value="di-cssmq-color(0)"/>
<sel:if expr="$nColors &gt; 0">
        <p>Your device can display <sel:value expr="$nColors"/> different colors.</p>
</sel:if>
 

In this example, variable nColors is set by a call to the function di-cssmq-color()(see 9.9 The di-cssmq-color function). This function returns the number of colors supported by the device. If the value is not zero, which indicates that the device does not support color, the paragraph is included in the result infoset. The value of the nColors variable appears in place of the sel:value element.

7 Attribute Value Templates

This section is normative.

DISelect extends the host language by allowing any attribute value to be specified as an Attribute Value Template (AVT). An AVT is an XPath expression which is evaluated to yield the value to be used for the attribute. To distinguish the use of an AVT as the value of an attribute, the expression must be enclosed in within curly braces.

Any AVT can contain any valid XPath expressions supported by the DISelect processor.

[XSLT] introduced the AVT and should be referred to for more infornation on its capabilities.

7.1 Using Attribute Value Templates

The examples in this section are informative.

The example illustrates the use of a variable within an attribute of the host language. Two variables are defined in the example. Variable isColor is set by a call to the function di-cssmq-color()(see 9.9 The di-cssmq-color function). This function returns a value of zero if the device does not support color. The value of isColor is used to control the value of variable preClass. This variable holds the name of the CSS style class used to provide styling definitions for the user experience. The different values of this class provide different styles appropriate for monochrome and color devices. The value of variable presClass is used in an AVT to specify the value of the class attributes on various elements in the host markup. The DISelect processor replaces the expressions in each AVT with the appropriate value, and this is subsequently used by the host language element.

<sel:variable name="isColor" value="di-cssmq-color(0)"/>
<sel:variable name="presClass" value="colorClass"/>
<sel:if expr="$isColor = 0">
    <sel:variable ref="presClass" value="greyClass"/>
</sel:if>
...
<h3 class="{$presClass}">Latest Cricket News</h3>
<dl class="{$presClass}">
    <dt>South Africa win latest one day international</dt>
    <dd>In a thrilling run chase, England yesterday just failed to overtake
    South Africa's mammoth score of 311.....</dd>
    <dt>Flintoff layoff will last four months</dt>
    <dd>Following recent surgery to correct a recurring injury problem, .......</dd>
</dl>

 

8 Expressions in DISelect

DISelect uses a subset of [XPath 1.0] to express the calculations and conditions involved when determining whether or not a particular piece of content is to be included for processing. This subset is sufficient to construct conditional expressions and expressions that return values. It also includes the ability to invoke XPath functions.

DISelect makes use of a number of specific XPath functions. These functions provide a means of abstraction that avoids direct coupling between the underlying data, on which conditional processing decisions are based, and the references used by authors. This is particularly useful in hiding the specific details of the representations used in delivery context from the markup that references it. A minimum set of such functions is described in Starter Set XPath Functions for Delivery Context Access.

It is anticipated that, in future,additional sets of functions that will be defined for more comprehensive access to the delivery context. The delivery context is essentially a set of metadata. Representations of delivery context, such as [CC/PP], use appropriate technologies such as RDF [RDF Primer]. Additional sets of functions developed in future for access to the delivery context are expected to provide interfaces that reflect its role as metadata while still hiding the details of the underlying representation.

8.1 Formal Grammar

The formal grammar for the XPath subset used in DISelect expressions is defined using the same, simple Extended Backus-Naur Form (EBNF) notation, as is used in [XPath 1.0].

[1]    DISelectExpr    ::=    DIExpr
[2]    DIPrimaryExpr    ::=    VariableReference
| '(' DIExpr ')'
| Literal
| Number
| DIFunctionCall
[3]    DIExpr    ::=    DIOrExpr
[4]    DIOrExpr    ::=    DIAndExpr
| DIOrExpr 'or' DIAndExpr
[5]    DIAndExpr    ::=    DIEqualityExpr
| DIAndExpr 'and' DIEqualityExpr
[6]    DIEqualityExpr    ::=    DIRelationalExpr
| DIEqualityExpr '=' DIRelationalExpr
| DIEqualityExpr '|=' DIRelationalExpr
[7]    DIRelationalExpr    ::=    DIAdditiveExpr
| DIRelationalExpr '<' DIAdditiveExpr
| DIRelationalExpr '>' DIAdditiveExpr
| DIRelationalExpr '<=' DIAdditiveExpr
| DIRelationalExpr '>=' DIAdditiveExpr
[8]    DIAdditiveExpr    ::=    DIUnaryExpr
[9]    DIUnaryExpr    ::=    DIPrimaryExpr
[10]    DIFunctionCall    ::=    DIFunctionName '(' ( DIExpr (, DIExpr ) * ) ? ')'
[11]    DIFunctionName    ::=    'di-cssmq-width ' |
| 'di-cssmq-height' |
| 'di-cssmq-device-width' |
| 'di-cssmq-device-height' |
| 'di-cssmq-device-aspect-ratio-width' |
| 'di-cssmq-device-aspect-ratio' |
| 'di-cssmq-device-aspect-ratio-height' |
| 'di-cssmq-color' |
| 'di-cssmq-color-index' |
| 'di-cssmq-monochrome' |
| 'di-cssmq-resolution' |
| 'di-cssmq-scan' |
| 'di-cssmq-grid'
| ExtensionFunctionName
ExtensionFunctionName

Additional functions that are available to the DISelect processor can be used within selection expressions. Such functions can be defined to the processor using the required element (see 5.9 The required Element). Such definitions allow the processor to verify the availability of the functions.

9 Starter Set XPath Functions for Delivery Context Access

The starter set XPath functions for delivery context access are intended to provide convenient, short hand forms for use by authors. The functions are derived from the facilities defined in [Media Queries]. They have been chosen to implement features similar to those associated with Media Queries. No attempt as been made to change the Media Queries function, except for two additions in the case of aspect ratio and the addition of a defaulting mechanism. It should be stressed that these particular functions are regarded as a minimum starter set.

In future, it is anticipated that additional sets of functions will be developed to provide more comprehensive access to the delivery context. It is also anticipated that access mechanisms that make explicit use of the underlying structure of the metadata within the delivery context will also be developed in future. These might, for example, make use of future capabilities to query RDF [RDF Primer].

9.1 Default Values

The starter set functions include a two stage mechanism for providing default values. Default values are returned by the functions when a value is not available from the delivery context.

First, authors can supply values to be returned in the event that the delivery context does not contain the appropriate information. They do this through the optional default parameter available on each function.

Second, each function provides a predefined default value that is returned if the delivery context does not contain the appropriate information and the author has not supplied a value through the default parameter to the function.

9.2 The di-cssmq-width function

This section is normative.

9.2.1 Prototype

number di-cssmq-width (string units, number default?)

string units

The units in which the value is to be returned. The possible values of this argument are described in detail in Length Units.

number default

An optional default value to be returned by the function if the usable display width cannot be determined from the delivery context.

9.2.2 Function

This function returns the usable width of the display associated with the device as a decimal number. This value may be smaller than that returned by the di-cssmq-device-width function. Some devices, for example, have fixed areas of their display that are unavailable to applications.

The function returns the value supplied in the defaultargument if the usable width cannot be determined from the delivery context. It returns 0 if the usable width cannot be determined from the delivery context and no defaultargument is provided.

9.2.3 Examples

This section is informative.

The expression

di-cssmq-width("px", 500) &gt; 400
 

returns the boolean value true, if the display has a usable width of more than 400 pixels, and falseotherwise. If the width cannot be determined from the delivery context, the function returns the default value 500, and consequently the expression evaluates to true.

Similarly the expression

di-cssmq-width("cm") &lt; 2.54
 

returns the boolean value true, if the display has a usable width of less than 2.54 centimeters and falseotherwise.

9.3 The di-cssmq-height function

This section is normative.

9.3.1 Prototype

number di-cssmq-height(string units, number default?)

string units

The units in which the value is to be returned. The possible values of this argument are described in detail in Length Units.

number default

An optional default value to be returned by the function if the usable display height cannot be determined from the delivery context.

9.3.2 Function

This function returns the usable height of the display associated with the device as a decimal number. This value may be smaller than that returned by the di-cssmq-device-height function. Some devices, for example, have fixed areas of their display that are unavailable to applications.

The function returns the value supplied in the defaultargument if the usable height cannot be determined from the delivery context. It returns 0 if the usable height cannot be determined from the delivery context and no defaultargument is provided.

9.3.3 Examples

This section is informative.

The expression

di-cssmq-height("px") &gt; 200
 

returns the boolean value true, if the display has a usable height of more than 200 pixels, and falseotherwise.

The expression

di-cssmq-height("cm", 2.54)
 

returns the usable height of the display in centimeters as an xs;decimalvalue or the value 2.54 if the height cannot be determined from the delivery context.

9.4 The di-cssmq-device-width function

This section is normative.

9.4.1 Prototype

number di-cssmq-device-width(string units, number default?)

string units

The units in which the value is to be returned. The possible values of this argument are described in detail in Length Units.

number default

An optional default value to be returned by the function if the physical display width cannot be determined from the delivery context.

9.4.2 Function

This function returns the physical width of the display associated with the device as a decimal number. This value may be larger than that returned by the di-cssmq-width function. Some devices, for example, have fixed areas of their display that are unavailable to applications.

The function returns the value supplied in the defaultargument if the physical width cannot be determined from the delivery context. It returns 0 if the physical width cannot be determined from the delivery context and no defaultargument is provided.

9.4.3 Examples

This section is informative.

The expression

di-cssmq-device-width("px") &lt; 640
 

returns the boolean value true, if the display has a physical width of less than 640 pixels, and falseotherwise. Similarly the expression

di-cssmq-device-width("in") &lt; 3.6
 

returns the boolean value true, if the display has a usable width of less than 3.6 inches and falseotherwise.

9.5 The di-cssmq-device-height function

This section is normative.

9.5.1 Prototype

number di-cssmq-device-height(string units, number default?)

string units

The units in which the value is to be returned. The possible values of this argument are described in detail in Length Units.

number default

An optional default value to be returned by the function if the physical display height cannot be determined from the delivery context.

9.5.2 Function

This function returns the physical height of the display associated with the device as a decimal number. This value may be smaller than that returned by the di-cssmq-device-height function. Some devices, for example, have fixed areas of their display that are unavailable to applications.

The function returns the value supplied in the defaultargument if the physical height cannot be determined from the delivery context. It returns 0 if the physical height cannot be determined from the delivery context and no defaultargument is provided.

9.5.3 Examples

This section is informative.

The expression

di-cssmq-device-height("cm") &gt; 2.7
 

returns the boolean value true, if the display has a physical height of more than 2.7 centimeters, and falseotherwise. If the physical height cannot be determined from the delivery context, the function returns the value 0and hence the expression evaluates to false.

The expression

di-cssmq-device-height("px", 250)
 

returns the physical height of the display in pixels as an xs;decimalvalue or the value 250 if the height cannot be determined from the delivery context.

9.6 The di-cssmq-device-aspect-ratio function

This section is normative.

9.6.1 Prototype

string di-cssmq-device-aspect-ratio(string default?)

string default

An optional default value to be returned by the function if the aspect ratio cannot be determined from the delivery context.

9.6.2 Function

This function returns a representation of the physical aspect ratio of the device in the form defined in [Media Queries]. The resulting string contains values such as 16/9, indicating an aspect ratio of 16:9, the ratio commonly associated with wide screen television, for example. The first value represents the width and the second value the height of the display. The complete value indicates the relative sizes of these dimensions. The values within the result are always the minimuminteger values that can represent the aspect ratio.

The function returns the value supplied in the defaultargument if the aspect ratio cannot be determined from the delivery context. It returns an empty string if the aspect ratio cannot be determined from the delivery context and no defaultargument is provided.

9.6.3 Examples

This section is informative.

The expression

di-cssmq-device-aspect-ratio() = "16/9"
 

returns the boolean value true, if the display has an aspect ratio of 16:9 and falseotherwise.

The expression

di-cssmq-device-aspect-ratio("4/3")
 

returns the string value representing the device aspect ratio. If the aspect ratio cannot be determined from the delivery context, the value "4/3"is returned.

9.7 The di-cssmq-device-aspect-ratio-width function

This section is normative.

9.7.1 Prototype

number di-cssmq-device-aspect-ratio-width(number default?)

numberdefault

An optional default value to be returned by the function if the width value of the aspect ratio cannot be determined from the delivery context.

9.7.2 Function

This function returns the width value of the aspect ratio of the display associated with the device. This value is the number representation of the firstvalue returned by the di-cssmq-device-aspect-ratio function. For example, if the di-cssmq-device-aspect-ratio were to return the string value "16/9", this function would return the number value 16.

The function returns the value supplied in the defaultargument if the width value of the aspect ratio cannot be determined from the delivery context. It returns a value of 0 if the width value of the aspect ratio cannot be determined from the delivery context and no defaultargument is provided.

9.7.3 Examples

This section is informative.

The expression

di-cssmq-device-aspect-ratio-width() = 16
 

returns the boolean value true, if the display has an aspect ratio width of 16 and falseotherwise.

The expression

di-cssmq-device-aspect-ratio-width(12)
 

returns the number value representing the width value of the aspect ratio. If the width value of the aspect ratio cannot be determined from the delivery context, the value 12is returned.

9.8 The di-cssmq-device-aspect-ratio-height function

This section is normative.

9.8.1 Prototype

number di-cssmq-device-aspect-ratio-height(number default?)

number default

An optional default value to be returned by the function if the height value of the aspect ratio cannot be determined from the delivery context.

9.8.2 Function

This function returns the height value of the aspect ratio of the display associated with the device. This value is the number representation of the secondvalue returned by the di-cssmq-device-aspect-ratio function. For example, if the di-cssmq-device-aspect-ratio were to return the string value "16/9", this function would return the number value 9.

The function returns the value supplied in the defaultargument if the height value of the aspect ratio cannot be determined from the delivery context. It returns a value of 0 if the height value of the aspect ratio cannot be determined from the delivery context and no defaultargument is provided.

9.8.3 Examples

This section is informative.

The expression

di-cssmq-device-aspect-ratio-height() = 9
 

di-cssmq-device-aspect-ratio-height() = 9

returns the boolean value true, if the display has an aspect ratio height of 9 and falseotherwise.

The expression

di-cssmq-device-aspect-ratio-height(6)
 

returns the number value representing the height value of the aspect ratio. If the height value of the aspect ratio cannot be determined from the delivery context, the value 6is returned.

9.9 The di-cssmq-color function

This section is normative.

9.9.1 Prototype

number di-cssmq-color(number default?)

number default

An optional default value to be returned by the function if the number of bits per color cannot be determined from the delivery context.

9.9.2 Function

This function returns the number of bits per color supported by the display associated with the device. The result is expressed as a positive integer.

The function returns the value supplied in the defaultargument if the number of bits per color cannot be determined from the delivery context. It returns 0 if the number of bits per color cannot be determined from the delivery context and no defaultargument is provided. The function also returns 0 if the device does not support color.

9.9.3 Examples

This section is informative.

The expression

di-cssmq-color() &gt; 4
 

returns the boolean value true, if the display supports more than 4 bits per color, and falseotherwise. Similarly the expression

di-cssmq-color(8) &gt; 6
 

returns the boolean value true, if the display supports more than 6 bits per color. It also returns trueif the number of bits per color cannot be determined from the delivery context. In this case, the function returns the supplied default value of 8, which is greater than 6.

9.10 The di-cssmq-color-index function

This section is normative.

9.10.1 Prototype

number di-cssmq-color(number default?)

number default

An optional default value to be returned by the function if the number of entries in the color look up table for the device cannot be determined from the delivery context.

9.10.2 Function

This function returns the number of entries in the color look up table of the display associated with the device. The result is expressed as a positive integer.

The function returns the value supplied in the defaultargument if the number of entries in the color look up table cannot be determined from the delivery context. It returns 0 if the number of entries in the color look up table cannot be determined from the delivery context and no defaultargument is provided. The function also returns 0 if the device does not support color or has no look up table.

9.10.3 Examples

This section is informative.

The expression

di-cssmq-color-index() &gt; 16

returns the boolean value true, if the color look up table of the display has more than 16 entries, and falseotherwise. Similarly the expression

di-cssmq-color-index(256) &gt; 64

returns the boolean value true, if the the color look up table of the display has more than 64 entries. It also returns trueif the number of entries in the color look up table cannot be determined from the delivery context. In this case, the function returns the supplied default value of 256, which is greater than 64.

9.11 The di-cssmq-monochrome function

This section is normative.

9.11.1 Prototype

number di-cssmq-monochrome(number default?)

number default

An optional default value to be returned by the function if the number of bits used to represent monochrome output cannot be determined from the delivery context.

9.11.2 Function

This function returns the number of bits used to represent monochrome output by the display associated with the device. The result is expressed as a positive integer.

The function returns the value supplied in the defaultargument if the number of bits used to represent monochrome output cannot be determined from the delivery context. It returns 0 if the the number of bits used to represent monochrome output cannot be determined from the delivery context and no defaultargument is provided. The function also returns 0 if the device does not support color.

9.11.3 Examples

This section is informative.

The expression

di-cssmq-monochrome() &gt; 4
 

returns the boolean value true, if the display uses more than 4 bits to represent monochrome output, and falseotherwise. Similarly the expression

di-cssmq-monochrome(8) &gt; 6
 

returns the boolean value true, if the display uses more than 6 bits to represent monochrome output. It also returns trueif the number of bits used to represent monochrome cannot be determined from the delivery context. In this case, the function returns the supplied default value of 8, which is greater than 6.

9.12 The di-cssmq-resolution function

This section is normative.

9.12.1 Prototype

number di-cssmq-resolution(string units, number default?)

string units

The units in which the value is to be returned. The possible values of this argument are described in detail in Resolution Units.

number default

An optional default value to be returned by the function if the resolution cannot be determined from the delivery context.

9.12.2 Function

This function returns the resolution of the display associated with the device as a decimal number.

The function returns the value supplied in the defaultargument if the resolution cannot be determined from the delivery context. It returns 0 if the resolution cannot be determined from the delivery context and no defaultargument is provided.

9.12.3 Examples

This section is informative.

The expression

di-cssmq-resolution("dpi", 100) &gt; 200
 

returns the boolean value true, if the display has a resolution of more than 200 pixels per inch, and falseotherwise. If the resolution cannot be determined from the delivery context, the function returns the default value 100, and consequently the expression evaluates to false.

9.13 The di-cssmq-scan function

This section is normative.

9.13.1 Prototype

string di-cssmq-scan(string default?)

string default

An optional default value to be returned by the function if the scan type cannot be determined from he delivery context.

9.13.2 Function

This function returns a representation of the type of scan used by the display associated with the device. The resulting string contains one of the following values.

progressive

The display uses a progressive scanning scheme

interlace

The display uses an interlace scanning scheme

The function returns the value supplied in the defaultargument if the type of scan cannot be determined from the delivery context. It returns an empty string if the type of scan cannot be determined from the delivery context and no defaultargument is provided.

9.13.3 Examples

This section is informative.

The expression

di-cssmq-scan() = "interlace"
 

returns the boolean value true, if the display uses interlace scanning and falseotherwise.

The expression

di-cssmq-scan("progressive")
 

returns the string value representing the type of scanning used. If the type of scan cannot be determined from the delivery context, the value "progressive"is returned.

9.14 The di-cssmq-grid function

This section is normative.

9.14.1 Prototype

boolean di-cssmq-grid(boolean default?)

boolean default

An optional default value to be returned by the function if it is not possible to determine whether the device is grid based or bitmap based from the delivery context.

9.14.2 Function

This function returns a boolean value of trueif the device is grid based. Grid based devices support a regular character array rather than a bitmap display. Examples of grid based devices include teletype terminals and simple mobile phones with fixed width fonts.

The function returns the value supplied in the defaultargument if it is not possible to determine whether the device is grid based or bitmap based from the delivery context. It returns falseif it is not possible to determine whether the device is grid based or bitmap based from the delivery context and no defaultargument is provided.

9.14.3 Examples

This section is informative.

The expression

di-cssmq-grid()
 

returns the boolean value true, if the display is grid based.

9.15 Units

9.15.1 Length Units

The starter set of XPath functions for accessing delivery context recognizes the following string literal values that specify length units.

px

the length is specified in pixels

in

the length is specified in inches

cm

the length is specified in centimeters

mm

the length is specified in millimeters

pt

the length is specified in font points

pc

the length is specified in picas

9.15.2 Resolution Units

The starter set of XPath functions for accessing delivery context recognizes the following string literal values that specify resolution units.

dpi

the resolution is specified as a number dots or pixels per inch

dpcm

the resolution is specified as a number dots or pixels per centimeter

dpmm

the resolution is specified as a number dots or pixels per millimeter

A Schema

The schema for DISelect is available as a W3C XML Schema.

B References

B.1 Normative References

IETF RFC 2119
RFC 2119: Key words for use in RFCs to Indicate Requirement Levels. Internet Engineering Task Force, 1997. (See http://www.ietf.org/rfc/rfc2119.txt.)
XHTML Modularization
Modularization of XHTML M. Altheim, et al., 2001. W3C Recommendation (See http://www.w3.org/TR/xhtml-modularization/.)
XML Names
Namespaces in XML (See http://www.w3.org/TR/REC-xml-names/.)
XPath 1.0
XML Path Language (XPath) Version 1.0 J. Clark et al., 1999. W3C Recommendation (See http://www.w3.org/TR/xpath.)
Media Queries
Media Queries Håkon Wium Lie et al., 2003. W3C Candidate Recommendation (See http://www.w3.org/TR/css3-mediaqueries/.)
XHTML 2
XHTML TM 2 J. Axelsson et al., 2003 W3C Working Draft (See http://www.w3.org/TR/xhtml2/.)
XML Infoset
XML Information Set (Second Edition) J. Cowan et al., 2004. W3C Recommendation (See http://www.w3.org/TR/xml-infoset/.)
DOM2 Events
Document Object Model (DOM) Level 2 Events Specification Tom Pixley, 2000. W3C Recommendation (See http://www.w3.org/TR/DOM-Level-2-Events/.)
XML Events
XML Events - An events syntax for XML Steven Pemberton et. al. W3C Proposed Recommendation (See http://www.w3.org/TR/xml-events/.)

B.2 Informative References

Glossary
Glossary of Terms for Device Independence R. Lewis, 2005 (See http://www.w3.org/TR/di-gloss/.)
Authoring Challenges
Authoring Challenges for Device Independence R. Lewis, 2003. W3C Note (See http://www.w3.org/TR/acdi/.)
DI Principles
Device Independence Principles R. Gimson, 2003. W3C Note (See http://www.w3.org/TR/di-princ/.)
CC/PP
Composite Capability/Preference Profiles (CC/PP): Structure and Vocabularies 1.0 G.Klyne, et al., 2004. W3C Recommendation (See http://www.w3.org/TR/CCPP-struct-vocab/.)
XForms
XForms 1.0 M. Dubinko et al., 2003 W3C Recommendation (See http://www.w3.org/TR/xforms/.)
CSS
Cascading Style Sheets, level 2 revision 1 B. Boss et al., 2004 W3C Candidate Recommendation (See http://www.w3.org/TR/CSS21/.)
RDF Primer
RDF Primer F. Manola et al., 2004 W3C Candidate Recommendation (See http://www.w3.org/TR/rdf-primer/.)
ECMAScript
ECMAScript Language Specification ECMA (European Computer Manufacturers Association) (See http://www.ecma-international.org/publications/standards/Ecma-262.htm.)
XSLT
XSL Transformations (XSLT) Version 1.0 J. Clark, 1999 W3C Recommendation (See http://www.w3.org/TR/xslt.)

C Changelog (Non-Normative)

C.1 Changes in this Version

  • Clarification of processing when required @functions are not found.

  • Add a reference to XSLT in our description of AVTs. AVTs are defined by XSLT not XPath.

  • Updated the definitions of the expr attribute on the value element and the value attribute on the variable element to make them consistent.

  • Updated the descriptions of events to include DOM2/XML Event information. This includes definition of the element that is the target of the event, whether or not the event can be cancelled, and whether or not it bubbles. Guidance on the particular values used was taken from the XForms specification. The default action taken by the DISelect processor was also rationalised into the tables used for this additional event information.

  • Added the sel:options element .

  • The sel:selidName attribute was introduced to overcome a possible ambiguity in the mechanism that specified both the value and the name of the unique identifier generated from the sel:selid attribute.

  • Clarify the use of data types for variables and make the use of XPath 1 normative in response to discussion at the 9th F2F meeting in Boston in March 2005.

  • Added the section describing Attribute Value Templates, as the mechanism for computing the values of host language attributes using expressions

  • Added the section describing the value element as the mechanism for including the values of expressions in the body content of host language elements.

  • Added the variable and value elements to the list of elements in the description of the selection module.

  • Added the mechanism for reprocessing the document in response to an event. This is based on the diselect-reprocess event.

  • Updated the conformance information to be closer to that in the latest QA specification guidelines

  • Added the mechanism for specifying the name of the attribute to be generated by the sel:selid attribute.

  • Added the mechanism for allowing a processor to check that extension functions are available. This is based on the new sel:required element.

  • Updated examples in the section on starter set XPath functions to use the same format as examples from earlier in the document.

  • Added the diselect-invalid-declaration exception. Updated the section on declaration of variables to describe the conditions under which it is raised.

  • Renamed the Examples sections

  • Corrected the reference to examples that illustrate sel:selid to point to the examples associated with content selection elements.

  • Reworded the description in the Overview.

  • Added an editorial note about whether the processing model as described is sufficient. It may not be able to handle dynamic situations in which the source infoset is repeatedly reprocessed.

  • Completed the processing model. Added the appropriate error events and described the conditions under which they are raised. Clarified the rules on types and variable declarations.

  • Added a formal syntax for the expressions used within DISelect.

  • Resolved comments that use of XPath 2 requires a host language to specify the types that are valid and that DISelect itself was not necessarily playing the role of the host language for XPath 2.

    The changes made make XPath 1 the expression language for this version of DISelect. The changes made were:

    Remove references to the use of XML schema types
    Update the function prototypes to use XPath 1 types rather than XPath 2 types
    Remove the definition of the use of the xs: prefix
    Remove the normative reference to XPath 2
    Remove the normative reference to XML Schema Part 1

  • Changed the prefix in the document associated with XML Schema from xsd: to xs: to reflect more common usage in W3C documents.

  • Changed the prefix in the document associated with delivery context from dc: to dcn: to avoid a clash with the prefix used by convention for Dublin Core.

  • Paul Duffin commented that the specification as written implied that a number of attributes were global. This was not the intent. The specification has been updated to reflect the author's true intent. Attributes need to be qualified only when used within elements that are not within the DISelect namespace.

    All unnecessary use of explicit prefixes has been removed. A comment has been added concerning the examples and indicating that they assume that XHTML Version 2 is the host language.

    The description of the use of the default namespace in this document has been updated to reflect the use of XHTML Version 2 as the host language in the examples.

D Acknowledgements (Non-Normative)

This document was produced with the participation of the Device Independence Working Group participants:

  • Augusto Aguilera, The Boeing Company
  • Stephane Boyera, W3C
  • Gabriel Guillaume, France Telecom
  • Rotan Hanrahan, Mobileaware, Ltd.
  • Rhys Lewis, Volantis Systems Ltd. (Chair, Editor)
  • Roland Merrick, IBM (Editor)
  • Fabio Paterno, CNR--Consiglio Nazionale delle Ricerche
  • Sailesh Sathish, Nokia
  • Andreas Schade, IBM
  • Todd Shingler, Mobileaware, Ltd.
  • Paul Walsh, Segala M Test
  • Keith Waters, France Telecom
  • Mark Watson, Volantis Systems Ltd.
  • Matt Womer, France Telecom

The Device Independence Working Group has benefited in its work from the participation and contributions of a number of people not currently members of the Working Group, including in particular those named below. Affiliations given are those current at the time of their work with the WG.

  • Roger Gimson, HP
  • Kazuhiro Kitagawa, W3C
  • Tayeb Lemlouma, INRIA Rhone-Alpes
  • Luu Tran, Sun Microsystems
  • Cedric Ulmer, SAP