XHTMLMP+SVGT: Combined Markup for Mobile Browsing - Recommended Practice

XHTMLMP+SVGT: Combined Markup for Mobile Browsing - Recommended Practice

Please note: Work on this specification is being continued in the W3C Compound Document Working Group (09. August 2005).

Current document: 05. November 2004 (14th update. ChangeLog at the end of this document.)

Introduction and Rational

This document gives guidens on how to create combined markup documents for mobile devices, based on XHTML Mobile Profile (XHTML-MP) and SVG Tiny (SVGT).

Combining these two technologies allows the creation of screenresolution-independent mobile content. Dynamic markup generation, based on user agent identification, will not be required.

Instead, when creating combined markup, content providers will use a least common denominator approach. This will allow them to provide content in static documents, by hosting it on a standard webserver.

Any device in the target device group will...

A conformance test suite for the following recommendations is available at http://lab.vodafone.com/xhtml-svgt11/index.xhtmlmp (URL points to mobile device markup).

Icon Mode SVGT vs. Full View SVGT

1. SVGT in Icon Mode

(1.1.1) Restrictions of icon mode SVGT

Link-references, interactivity (two-way focus navigation and user events) and zoom-and-pan are NOT supported in icon mode.

(1.1.2) Allowing the user to switch from icon mode to full view mode

An SVGT icon, referenced from XHTML, MAY be wrapped with an anchor tag pointing to itself...
<a href="bar.svg"> 
  <object data="bar.svg" type="image/svg+xml" width="80" />
</a>
...so that the SVGT icon can be clicked on and brought to full view mode. If zoom-and-pan functionality is required then, the 'zoomAndPan="disable"' attribute should NOT have been set in the SVGT document. (SVG Example)

(1.3) SVGT and xembedded bitmap images

Bitmap images (PNG, JPEG, GIF) may be referenced from within icon mode SVGT.

(1.4.1) XHTML browser drawing outline for SVGT icon wrapped by a focused anchor

An xembedded SVGT may be wrapped with an XHTML anchor element, so that it can point to another XHTML document (for instance).
<a href="http://live.vodafone.com/foo.html">
  <object data="bar.svg" type="image/svg+xml" width="40%" />

</a>
The XHTML browser will draw an outline for all objects wrapped by the anchor tag. The outline will be drawn using a default color. (SVG Example)

(1.4.2) Hiding focus outline (over SVG icon) using CSS

The XHTML focus outline color MAY be modified using CSS. The outline MAY also be made fully invisible using CSS.

The following code will cause all XHTML anchors with class 'svglink' to have no outline when they receive focus:
<style type="text/css">
  a.svglink:focus { outline: none }
</style>
<a href="foo.html" class="svglink">
  <object data="triggered-animate.svg" type="image/svg+xml" width="40%" />
</a>
The ability to hide the default outline visualisation creates the basis for content driven focus-highlighting (see 1.4.3). Hiding the outline visualisation makes sense only, if the SVG object itself takes care of visual feedback when it gains/looses focus.

(1.4.3) XHTML focus events to trigger SVGT animations

The host XHTML browser triggers "focusin", "focusout" and "activate" events to the root <svg> element of each SVGT document wrappped by the XHTML anchor tag, receiving focus. This applies to declarative animation:
<svg id="SVGRoot">
  ...
  <rect ... >
    <animate begin="SVGRoot.focusin" ... />
    <animate begin="SVGRoot.focusout" ... />
  </rect>
  ...
</svg>

In order to allow for the SVG playback to suspend their processing when they are not supposed to animate, the following parameter may be applied in the XHTML:

1. <param name="animation" value="play" /> (default)

This SVG object should play/animate all the time. focusin/focusout/activate events will be handled at any time.

2. <param name="animation" value="stop" />

This SVG object will only render the first frame for time zero (0) and then suspend indefinitely. This may be used for "static" SVG icons.

3. <param name="animation" value="onfocusevent" />

This SVG object will only render the first frame for time zero (0) and then suspend until it receives a focusin event. After receiving a focusin event the object will animate until a focusout event is received, when it will again suspend its timer and resume to a "paused" state.

The following XHTML sample code makes use of focus events in order to implement SVG based focus animations on multiple anchor objects. The automatic focus outline of the user agent is being disabled using CSS.

<style type="text/css">
  a.svglink:focus { outline: none }
</style>

<object type="image/svg+xml" data="header.svg" />  <!-- defaults to 'play' -->

<a href="foo1.html" class="svglink">
  <object type="image/svg+xml" data="foo1.svg">
    <param name="animation" value="onfocusevent" />  
  </object>
</a>

<a href="foo2.html" class="svglink">
  <object type="image/svg+xml" data="foo2.svg">
    <param name="animation" value="onfocusevent" />  
  </object>
</a>
Please note: In the SVG content, ...
- the 'focusin'-animation is not timewise limited and may loop any number of times
- the 'focusout'-animation should be limited to one second
- the 'focusout'- and 'activate'-animations must not loop

(1.4.4) Multiple SVGT icons referenced from XHTML (grid layout / 4-way navigation)

Multiple SVGT icon objects MAY be referenced from a single XHTML document. All of them MAY have their own anchor tag, allowing the creation of a multiselection menu page. The ability to use XHTML table to wrap multiple SVGT icons enables the creation of grid layouts and thereby the use of 4-way navigation over SVGT icons.

(1.5.1) Setting SVGT icon dimensions / Rightsizing

The dimension of an xembedded SVGT icon is determined by the following rules:
When using SVGT icons to create screenresolution independent layout in XHTML , content author should:
By setting only one of the XHTML object-element attributes width or height, both width and height attributes of the SVGT root-element will be overridden. The value of the 'not provided' attribute will be calculated based on the SVG's viewbox dimensions.

In icon mode, the destination rendering area (viewport) will automatically adjust to the aspect ratio of the viewbox attribute on the outermost SVG element. This means, that the hosting browser will (try to) reserve only the screen area needed to display the scaled SVG object. Following XHTML elements will be placed just right or below the xembedded SVG object.

(1.5.2) Banner type SVGT icons adjust themselfs to any width

The following is making use of (1.5.1, rule a).

If only one of the XHTML object width or height attributes is set, the user agent will automatically scale the other property proportionally, by inspecting the viewBox attributes of the <svg> root element (of the referenced SVGT document). The use of the XHTML object-element width attribute set to "100%" (with no height attribute given)...
<object data="foo.svg" type="image/svg+xml" width="100%" />
...is expected to become a common use case for small screen mobile devices, when creating banner-like objects, spreading over the full width of the screen (or a table cell), independent of the actual size of the screen (SVG Example).

However, in some cases will it not be possible to scale the SVG object (it's viewbox) according to the given XHTML width or height attribute.

The illustration below shows, on the left: two rendering areas with different aspect ratio (5:1 and 3:4). In the middle: two different SVG objects (green and red). And to the right: the two SVG's, each scaled into the both rendering areas (the lite blue areas are under control of the SVG, but outside of the SVG's viewbox).




(1) Rightsizing the green, 1:3 tall SVG object into the flat 5:1 box does not work really well. (Long before the full width of the rendering area is reached, will the object reach the maximum height of the rendering area. Large parts of the occupied rendering area will not be usable for content that is positioned inside the SVG's viewbox.)

(2) Rightsizing the red, 4:1 wide SVG object into in the flat 5:1 box works quite well, but some small non-filled margins still appear to the left and right of the scaled SVG object.

(3) Rightsizing the green, 1:3 tall SVG object into in the tall 3:4 box works also quite well, but here again, it is not possible to scale the SVG to the full width of the destination box.

(4) At first sight, rightsizing the red, 4:1 wide SVG object into the tall 3:4 box does not appear to work well. But, out of all four cases, this is the one case, where the SVG object does in fact scale up to the requested 100% width of the rendering area. This time, the UA has a possibility (and is also expected) to adjust the height of the destination box, to match the height of the scaled SVG object. As a result, there will be no non-filled margins (lt. blue), as visible in the other three samples.

In the modified illustration below, sample (4) now shows the desired effect. The SVG object was scaled up to the width of the destination box, as much as possible. And the UA has adjusted the vertical dimension of the destination box, as much as possible. Now, other content can be applied just below the SVG banner object.




Conclusion: When using a fixed aspect ratio, it will not be not possible to rightsize any SVG object into any destination box. It is, however, possible, to rigthsize a wide SVG object into a tall destination box. The UA MAY then be able to shrink the remaining other dimension of the destination box, so that no areas outside the SVG's viewbox become visible.

(Please note, that the behaviour shown above is supported for bitmap images in current desktop browsers. It is currently not supported for SVG objects, as it is most likely not possible for these browsers to retrieve the scaled 'other' dimension of the SVG object).

More about non-filled margins can be found under "(2.1.2) Fixed aspect ratio, scaling and resulting non-filled margins".

(1.5.3) Scaling may not be wanted for SVG objects with embedded bitmap images

The following is making use of (1.5.1, rule b).

In case a SVG document contains bitmap images, the content author may NOT want to allow the complete SVG object to scale at all. Such SVG documents SHOULD be provided with width and height on it's root <svg> element defined with fixed (non relative) values. The display size of such a SVGT document SHALL NOT be overridden by the XHTML object tag's width or height attributes (through CSS or XHTML). (XHTML Example)



(1.6) Multiple animating SVGT icons

From within a single XHTML document, multiple SVGT objects may be referenced and be displayed in parallel. All of these SVGT objects may animate in parallel. (This, however, is expected to create performance problems and content authors should use this with care. Content authors must also be aware, that there are limits for the combined data size of all displayed SVGT's.) (XHTML Example)

(1.7) Prefer the XHTML object-element over img/embed-elements to xembed SVGT icons

From within XHTML documents, SVGT objects MUST always be referenced using the <object> element, instead of using the <img> or <embed> element. XHTML authors may leverage the <object> element's fallback behavior in order to cater for cases where an SVGT renderer is not available on the device:
<object data="animated_image.svgz" 
        width="..." 
        height="..." 
        type="image/svg+xml">
  <img src="static_image.png" 
       width="..." 
       height="..." 
       alt="..." />
</object>

(1.8) SVGT icon declarative animations (and XHTML overlap)

Full declarative animations are always supported for foreground SVGT objects. In case other XHTML objects temporarily overlap such an animating foreground SVGT (a pull down menu, or similar), the animation MIGHT stop (timeline MIGHT pause) for as long as the overlap takes place. (XHTML Example)

(1.9) Use CSS positioning to allow XHTML overlays

The browser's CSS is expected to support absolute positioning.
<html>
  <object data="foo.svgz" 
          style="position:absolute; left:20; top:20; width:50" />
  <p style="position:absolute; left:20; top:20">
    This text should appears in front of the SVG document, since it is defined below .
  </p>
</html>

2. SVGT in Full View Mode

(2.1.0) Standalone (primary content) full view mode SVGT objects

The following is making use of (1.5.1, rule c).

The default values for width and height attributes within an SVGT document are "100%". SVGT object destined to be displayed in full view mode should be created with the width and height attributes not set (use their default value of 100%), so that they can be scaled to full view mode, when provided as primary content.

Authors are encouraged to use the "viewBox" attribute to specify the aspect ratio of the SVGT document.

(2.1.2) Fixed aspect ratio, scaling and resulting non-filled margins

If the destination box is the full browser view, then, scaling up a (primary type) SVG object (fixed aspect ratio assumed), will most likely not allow the SVG content (within it's viewbox dimensions) to fill up the full destination box.

For instance, if a SVG document with a square aspect ratio (defined by it's viewbox) is to be rendered into full view, and the available full view has a different aspect ratio (for instance 3 by 4), then there will be non-filled margins above and below the SVG content.



These margins can however be filled from within the SVG content, by defining elements outside the specified viewbox. The full visible background color may, for instance, be set, by defining a rectangle with dimensions larger than the viewbox and it's origins in the negative X/Y area. Such a rectangle, to set the full view background color, should directly follow the opening SVG root element, in order to not accidently overlap contents:
<svg viewBox="0 0 100 200">
  <rect x="-1000" y="-1000" width="2100" height="2200" fill="red"/>
  ...
</svg>
Content authors should also be aware that animation objects put right outside the viewbox (to be invisible) MAY STILL BE VISIBLE, depending on the aspect ratio of the destination rendering area. We suggest to make use of the visibility attribute to hide SVG objects when necessary.
<svg viewBox="0 0 100 200">
  <rect x="-50" y="0" width="50" height="50" fill="red" visibility="hidden">
    <set attributeName="visibility" to="visible" ... />
    ...
  </rect>
</svg>

(2.4) No scroll bars in full view SVGT

Because SVGT objects are never scaled to be larger than the full screen size, scroll bars are NOT enabled to display SVGT objects. Width/height values larger than 100% MAY be considered as content errors or MAY be treated as 100%. Scroll bars MAY be provided in "zoomAndPan" mode (if not disabled by the SVGT-object).

(2.6) SVGT as XHTML background image

SVGT objects MAY be used as fullview-background images (fullview = fullscreen minus browser chrome), independent of the amount of foreground XHTML content.
<html>
  <body style="background-image:url(background-noanim.svgz);background-attachment:fixed">
    <p>This in foreground</p>  
  </body>
</html>
  
To be used as a scalable background image, the witdh and height attributes of the SVG root element should not be set (or set to 100%). It is also suggested for the "background-attachment" attribute of the XHTML CSS to be set to "fixed", so that the fullview image does not scrol together with foreground elements.

Support for SVG animations, when used as XHTML background, is unlikely.

(2.7) SVGT nesting is not supported

Nesting SVGT inside SVGT (<svg><svg>...</svg></svg>) is not supported.

(2.8) Zoom-and-pan (in full view mode only)

Zoom-and-pan is expected to be supported only in full view mode. Key mappings and menu function for "zoomAndPan" are device/implementation specific. If not needed, content providers can disable Zoom-and-pan by providing the 'zoomAndPan="disable"' attribute. (SVG Example)

(2.9) Links and interactivity (in full view mode only)

In full view mode, links and interactivity are supported.

Additional requirements independent of the rendering mode:

3. GZIP Support

(3.1) GZIP support is mandatory in SVG(T)

All implementations support GZIP encoded SVGT content.

(3.3) GZIP MAY be used as encoding, NOT as 'content type'

"image/svg+xml" MUST be used as 'content type'.

5. Transparency

(5.1) Transparency between foreground SVGT and non-SVGT background is supported.

Example: foreground SVGT over a background JPEG referenced from XHTML supports transparency.

(5.2) Transparency between foreground SVGT and background SVGT is supported

In case both are rendered from a single SVGT document.

(5.3) Transparency between foreground bitmap images and animating background SVGT is NOT supported

(5.4) Transparency between foreground bitmap images and non-animating background SVGT IS supported

6. Fonts

(6.1) SVG Font support

The SVG Mobile specification only mandates SVG Fonts technology. (SVG fonts are delivered to the terminal together with the SVG markup.) Using SVG fonts, content authors can assume the graphical aspect of their text will be preserved and full animation capabilities do apply. (SVG fonts can be generated from other vector fonts on the PC.)

(6.2.1) System Font support

System font support is not fully specified. (There are two types of system fonts: Bitmap and Outline. Bitmap system fonts, which will most likely be the same as used for XHTML rendering, greatly enhance readability of small text, especially when combined with hinting. Outline system fonts provide greater flexibility in regard to font-size and animation).

However, the following, very basic text definition should always work out:
<svg ...>
  <text x="20" y="20" font-size="normal" fill="#000">Sample Text</text>
</svg>

(6.2.2) System Font naming and fallback mechanism

Implementations providing more than one system font, are expected to support the following font naming: 'serif', 'sans-serif', 'monospace', 'cursive', and 'fantasy'. (In practice 'cursive' is rare and 'fantasy' next to non-existent.) The same author friendly CSS font fallback mechanism is supported as in XHTML environments.

7. SVG Performance Index

(7.1) Dynamically adjust CPU intensive markup to better performing devices

Different SVGT implementations are expected to provide full SVGT markup compatibility, but may at the same time differ significantly in rendering and animation performance. An SVG performance indicator, provided via HTTP request and evaluated dynamically, will allow the generation of performance optimized content.

SVG-Perf description
0 none animating very low perf (Arm7 <30MHz)
1* none animating low perf (Arm7 <60MHz)
2 none animating high perf (Arm7 >=60MHz)
3 animating low perf (Arm7 >=90MHz)
4 animating mid perf (Arm7 >=120MHz / ~6600)
5 animating high perf (Arm7 >=120MHz + HW-accel)
6 animating high perf (low gradient/opacity) (Arm7 >=150MHz)
7 animating high perf (mid gradient/opacity) (Arm9 >=150MHz)
8 animating +gradient +opacity high perf (Arm9 >=180MHz)
9 animating +gradient +opacity very high perf (Arm9 >=180MHz + HW-accel)
10+ to be defined...


If no SVG-Perf index is provided, then 1 (=none animating low perf) is assumed.

8. Advertising SVG version and capabilities

(8.1) SVG Version and SVG Performance Index

The list of supported SVG profiles and the SVG Performance Index are fundamental informations to content authors. Both informations are therefore being provided together with the HTTP Accept-header as an extension of the SVG MIME type:
  "Accept: text/html, ..., image/svg+xml; ver=T1.1:T1.2; PI=5, image/png, ..."
Rational: The plugin-nature of many existing SVG(T) rendering components and the fact that these plugins are (at least in part) user installable makes it almost impossible to propose a UAProf based solution for these values. Especially when considering the limitations of current plugin-interfaces. A plugin-host (browser) is however expected to permit the plugin to provide a MIME type string during initialization.

The following Java code may be used to evaluate the HTTP Accept string for extended SVG info:
  evalAccept(String accept)
  {
    // accept = "text/html, ..., image/svg+xml; ver=T1.1:T1.2; PI=5, image/png, ...";
    System.out.println("Accept=["+accept+"]");

    StringTokenizer st = new StringTokenizer(accept,",");
    while(st.hasMoreTokens()) 
    {
      String mimeType = st.nextToken().trim();
      if(mimeType.startsWith("image/svg+xml"))
      {
        StringTokenizer st2 = new StringTokenizer(mimeType,";");
        while(st2.hasMoreTokens()) 
        {
          String str = st2.nextToken().trim();
          if(str.startsWith("ver="))
          {
            StringTokenizer st3 = new StringTokenizer(str.substring(4),":");
            while(st3.hasMoreTokens()) 
            {
              String version = st3.nextToken().trim();
              System.out.println("ver="+version);
            }
          }
          else
          if(str.startsWith("PI="))
          {
            String pI = str.substring(3);
            System.out.println("PI="+pI);
          }
        }
      }
    }
  }


This is what the above code would print out:
  Accept=[text/html, ..., image/svg+xml; ver=T1.1:T1.2; PI=5, image/png, ...]
  ver=T1.1
  ver=T1.2
  PI=5

Comments and Thanks

Please comment to timur.mehrvarz@vodafone.com

Special thanks to: Motorola, Adobe, Access, Sharp, Zoomon, BitFlash, SVG Consortium, BeatWare, NEC, Openwave, Opera, Antoine Quint, lars.piepel@vodafone.com, bruno.rodrigues@vodafone.com

Document changes: