# 0. XHTML Applet Module

Contents

This section is normative.

This module is deprecated. Similar functionality can be found in the Object Module.

The Applet Module provides elements for referencing external: applications. Specifically, the Applet Module supports the following elements and attributes:

Element | Attributes | Minimal Content Model
--- | --- | ---
applet | Core, alt* (Text), archive (CDATA), code (CDATA), codebase (URI), height* (Length), object (CDATA), width* (Length) | (PCDATA | Flow | param)*
param | id (ID), name* (CDATA), type (ContentType), value (CDATA), valuetype ("data"* | "ref" | "object") | EMPTY

When the Applet Module is used, it adds the `applet` element to the Text content set of the Inline Text Module.

Implementations: DTD, XML Schema

## 0.1. The applet element

This element, supported by all Java-enabled browsers, allows designers to embed a Java applet in an XHTML document. It has been Deprecated. in favor of the object element.

Attributes

The Core collection
  A collection of basic attributes used on all elements, including @class, @id or @xml:id, @layout, and @title.

  Attribute Style not found

  The attribute Style was not able to be loaded by the document generator. This implies that either 1) the attribute is not yet defined, or 2) the name is incorrect.

codebase = URI
  This attribute specifies the base URI for the applet. If this attribute is not specified, then it defaults the same base URI as for the current document. Values for this attribute may only refer to subdirectories of the directory containing the current document.

code = CDATA
  This attribute specifies either the name of the class file that contains the applet's compiled applet subclass or the path to get the class, including the class file itself. It is interpreted with respect to the applet's codebase. One of @code or @object must be present.

archive = URIs
  This attribute may be used to specify a space-separated list of URIs for archives containing resources relevant to the object, which may include the resources specified by the @src attribute.

object = CDATA
  This attribute names a resource containing a serialized representation of an applet's state. It is interpreted relative to the applet's codebase. The serialized data contains the applet's class name but not the implementation. The class name is used to retrieve the implementation from a class file or archive.

  When the applet is "deserialized" the `start()` method is invoked but not the `init()` method. Attributes valid when the original object was serialized are not restored. Any attributes passed to this applet instance will be available to the applet. Authors should use this feature with extreme caution. An applet should be stopped before it is serialized.

  Either @code or @object must be present. If both @code and @object are given, it is an error if they provide different class names.

width = MultiLength

  This attribute specifies a default width for each column in the current colgroup, or the width for each column spanned by the current col element. In addition to the standard pixel, percentage, and relative values, this attribute allows the special form "0*" (zero asterisk) which means that the width of each column in the group should be the minimum width necessary to hold the column's contents. This implies that a column's entire contents must be known before its width may be correctly computed. Authors should be aware that specifying "0*" will prevent visual user agents from rendering a table incrementally.

  This attribute is overridden for any column in the column group whose @width is specified via a col element.

  This attribute when used with the col element refers to the width of each column in the element's span.

height = Length
  This attribute specifies the initial height of the element's display area.

alt = Text
  For user agents that cannot display images, forms, or applets, this attribute specifies alternate text. The language of the alternate text is specified by the @xml:lang attribute.

  Several non-textual elements let authors specify alternate text to serve as content when the element cannot be rendered normally. Specifying alternate text assists users without graphic display terminals, users whose browsers don't support forms, visually impaired users, those who use speech synthesizers, those who have configured their graphical user agents not to display images, etc.

  While alternate text may be very helpful, it must be handled with care. Authors should observe the following guidelines:

  - Do not specify irrelevant alternate text when including images intended to format a page, for instance, `alt="red ball"` would be inappropriate for an image that adds a red ball for decorating a heading or paragraph. In such cases, the alternate text should be the empty string (""). Authors are in any case advised to avoid using images to format pages; style sheets should be used instead.
  - Do not specify meaningless alternate text (e.g., "dummy text"). Not only will this frustrate users, it will slow down user agents that must convert text to speech or braille output.

align = `"bottom|middle|top|left|right"`
  This attributes specifies the position of an element's content with respect to its context.

hspace = Pixels
  This attribute specifies the amount of white space to be inserted to the left and right of the element's content. The default value is not specified, but is generally a small, non-zero length.

vspace = Pixels
  This attribute specifies the amount of white space to be inserted above and below the element's content. The default value is not specified, but is generally a small, non-zero length.

The content of the `applet` acts as alternate information for user agents that don't support this element or are currently configured not to support applets. User agents must ignore the content otherwise.

DEPRECATED EXAMPLE:
In the following example, the `applet` element includes a Java applet in the document. Since no `codebase` is supplied, the applet is assumed to be in the same directory as the current document.

    <applet code="Bubbles.class" width="500" height="500">
    Java applet that draws animated bubbles.
    </applet>

This example may be rewritten with `object` as follows:

    <P><object codetype="application/java"
            classid="java:Bubbles.class"
            width="500" height="500">
    Java applet that draws animated bubbles.
    </object>

Initial values may be supplied to the applet via the `param` element.

DEPRECATED EXAMPLE:
The following sample Java applet:

    <applet code="AudioItem" width="15" height="15">
    <param name="snd" value="Hello.au|Welcome.au">
    Java applet that plays a welcoming sound.
    </applet>

may be rewritten as follows with `object`:

    <object codetype="application/java"
            classid="AudioItem"
            width="15" height="15">
    <param name="snd" value="Hello.au|Welcome.au">
    Java applet that plays a welcoming sound.
    </object>

## 0.2. The param element.

Attributes

name = CDATA
  This attribute defines the name of a run-time parameter, assumed to be known by the object handler. Whether the property name is case-sensitive depends on the specific object handler implementation.

value = CDATA
  This attribute specifies the value of a run-time parameter specified by @name. Property values have no meaning to XHTML; their meaning is determined by the object in question.

valuetype = `data|ref|object`
  This attribute specifies the type of the `value` attribute.

  Possible values:

  - `data:` This is the default value for the attribute. It means that the value specified by @value will be evaluated and passed to the object's implementation as a string.
  - `ref:` The value specified by @value is a URI that designates a resource where run-time values are stored. This allows support tools to identify URIs given as parameters. The URI must be passed to the object as is, i.e., unresolved.
  - `object:` The value specified by @value is an identifier that refers to an object declaration in the same document. The identifier must be the value of the @id attribute set for the declared object element.

type = ContentType
  This attribute specifies the content type of the resource designated by the @value attribute only in the case where @valuetype is set to "ref". This attribute thus specifies for the object handler, the type of values that will be found at the URI designated by @value.

`PARAM` elements specify a set of values that may be required by an object at run-time. Any number of `PARAM` elements may appear in the content of an `OBJECT` or `APPLET` element, in any order, but must be placed at the start of the content of the enclosing `OBJECT` or `APPLET` element.

The syntax of names and values is assumed to be understood by the object's implementation. This document does not specify how user agents should retrieve name/value pairs nor how they should interpret parameter names that appear twice.

We return to the clock example to illustrate the use of `PARAM`: suppose that the applet is able to handle two run-time parameters that define its initial height and width. We can set the initial dimensions to 40x40 pixels with two `PARAM` elements.

    <P><OBJECT classid="http://www.miamachina.it/analogclock.py">
    <PARAM name="height" value="40" valuetype="data">
    <PARAM name="width" value="40" valuetype="data">
    This user agent cannot render Python applications.
    </OBJECT>

In the following example, run-time data for the object's "Init_values" parameter is specified as an external resource (a GIF file). The value of the `valuetype` attribute is thus set to "ref" and the `value` is a URI designating the resource.

    <P><OBJECT classid="http://www.gifstuff.com/gifappli"
           standby="Loading Elvis...">
    <PARAM name="Init_values"
           value="./images/elvis.gif">
           valuetype="ref">
    </OBJECT>

Note that we have also set the `standby` attribute so that the user agent may display a message while the rendering mechanism loads.

When an `OBJECT` element is rendered, user agents must search the content for only those `PARAM` elements that are direct children and "feed" them to the `OBJECT`.

Thus, in the following example, if "obj1" is rendered, "param1" applies to "obj1" (and not "obj2"). If "obj1" is not rendered and "obj2" is, "param1" is ignored, and "param2" applies to "obj2". If neither `OBJECT` is rendered, neither `PARAM` applies.

    <P>
    <OBJECT id="obj1">
       <PARAM name="param1">
       <OBJECT id="obj2">
          <PARAM name="param2">
       </OBJECT>
    </OBJECT>

### 0.2.1. Global naming schemes for objects

The location of an object's implementation is given by a URI. The first segment of an absolute URI specifies the naming scheme used to transfer the data designated by the URI. For XHTML documents, this scheme is frequently "http". Some applets might employ other naming schemes. For instance, when specifying a Java applet, authors may use URIs that begin with "java" and for ActiveX applets, authors may use "clsid".

In the following example, we insert a Java applet into an XHTML document.

    <P><OBJECT classid="java:program.start">
    </OBJECT>

By setting the `codetype` attribute, a user agent can decide whether to retrieve the Java application based on its ability to do so.

    <OBJECT codetype="application/java-archive"
            classid="java:program.start">
    </OBJECT>

Some rendering schemes require additional information to identify their implementation and must be told where to find that information. Authors may give path information to the object's implementation via the `codebase` attribute.

    <OBJECT codetype="application/java-archive"
            classid="java:program.start">
            codebase="http://foooo.bar.com/java/myimplementation/"
    </OBJECT>

The following example specifies (with the `classid` attribute) an ActiveX object via a URI that begins with the naming scheme "clsid". The `data` attribute locates the data to render (another clock).

    <P><OBJECT classid="clsid:663C8FEF-1EF9-11CF-A3DB-080036F12502"
            data="http://www.acme.com/ole/clock.stm">
    This application is not supported.
    </OBJECT>

### 0.2.2. Object declarations and instantiations

The preceding examples have only illustrated isolated object definitions. When a document is to contain more than one instance of the same object, it is possible to separate the declaration of the object from its instantiations. Doing so has several advantages:

- Data may be retrieved from the network by the user agent one time (during the declaration) and reused for each instantiation.
- It is possible to instantiate an object from a location other than the object's declaration, for example, from a link.
- It is possible to specify objects as run-time data for other objects.

To declare an object so that it is not executed when read by the user agent, set the boolean `declare` attribute in the `OBJECT` element. At the same time, authors must identify the declaration by setting the `id` attribute in the `OBJECT` element to a unique value. Later instantiations of the object will refer to this identifier.

A declared `OBJECT` must appear in a document before the first instance of that `OBJECT`.

An object defined with the `declare` attribute is instantiated every time an element that refers to that object requires it to be rendered (e.g., a link that refers to it is activated, an object that refers to it is activated, etc.).

In the following example, we declare an `OBJECT` and cause it to be instantiated by referring to it from a link. Thus, the object can be activated by clicking on some highlighted text, for example.

    <P><OBJECT declare
            id="earth.declaration"
            data="TheEarth.mpeg"
            type="application/mpeg">
       The <STRONG>Earth</STRONG> as seen from space.
    </OBJECT>
    ...later in the document...
    <P>A neat <A href="#earth.declaration"> animation of The Earth!</A>

The following example illustrates how to specify run-time values that are other objects. In this example, we send text (a poem, in fact) to a hypothetical mechanism for viewing poems. The object recognizes a run-time parameter named "font" (say, for rendering the poem text in a certain font). The value for this parameter is itself an object that inserts (but does not render) the font object. The relationship between the font object and the poem viewer object is achieved by (1) assigning the `id` "tribune" to the font object declaration and (2) referring to it from the `PARAM` element of the poem viewer object (with `valuetype` and `value`).

    <P><OBJECT declare
         id="tribune"
         type="application/x-webfont"
         data="tribune.gif">
    </OBJECT>
    ...view the poem in KublaKhan.txt here...
    <P><OBJECT classid="http://foo.bar.com/poem_viewer"
               data="KublaKhan.txt">
    <PARAM name="font" valuetype="object" value="#tribune">
    <P>You're missing a really cool poem viewer ...
    </OBJECT>

User agents that don't support the `declare` attribute MUST render the contents of the `OBJECT` declaration.