6.3. HTML

This module defines functions and classes for working with HTML documents. The version of the standard implemented is, loosely speaking, the HTML 4.0.1 Specification: http://www.w3.org/TR/html401/

This module contains code that can help parse HTML documents into classes based on the basic xml sub-package, acting as a gateway to XHTML. The module is designed to provide just enough HTML parsing to support the use of HTML within other standards (such as Atom and QTI).

6.3.1. (X)HTML Documents

The namespace to use in the delcaration of an XHTML document:

pyslet.html401.XHTML_NAMESPACE
class pyslet.html401.XHTMLDocument(**args)

Bases: pyslet.xml.namespace.NSDocument

Represents an HTML document.

Although HTML documents are not always represented using XML they can be, and therefore we base our implementation on the pyslet.xml.namespace.NSDocument class, the namespace-aware variant of the basic pyslet.xml.Document class.

class_map = {('http://www.w3.org/1999/xhtml', 'dl'): <class 'pyslet.html401.DL'>, ('http://www.w3.org/1999/xhtml', 'ins'): <class 'pyslet.html401.Ins'>, ('http://www.w3.org/1999/xhtml', 'optgroup'): <class 'pyslet.html401.OptGroup'>, ('http://www.w3.org/1999/xhtml', 'thead'): <class 'pyslet.html401.THead'>, ('http://www.w3.org/1999/xhtml', 'isindex'): <class 'pyslet.html401.IsIndex'>, ('http://www.w3.org/1999/xhtml', 'strike'): <class 'pyslet.html401.Strike'>, ('http://www.w3.org/1999/xhtml', 'h2'): <class 'pyslet.html401.H2'>, ('http://www.w3.org/1999/xhtml', 'frameset'): <class 'pyslet.html401.Frameset'>, ('http://www.w3.org/1999/xhtml', 'basefont'): <class 'pyslet.html401.BaseFont'>, ('http://www.w3.org/1999/xhtml', 'br'): <class 'pyslet.html401.Br'>, ('http://www.w3.org/1999/xhtml', 'param'): <class 'pyslet.html401.Param'>, ('http://www.w3.org/1999/xhtml', 'input'): <class 'pyslet.html401.Input'>, ('http://www.w3.org/1999/xhtml', 'fieldset'): <class 'pyslet.html401.FieldSet'>, ('http://www.w3.org/1999/xhtml', 'acronym'): <class 'pyslet.html401.Acronym'>, ('http://www.w3.org/1999/xhtml', 'u'): <class 'pyslet.html401.U'>, ('http://www.w3.org/1999/xhtml', 'strong'): <class 'pyslet.html401.Strong'>, ('http://www.w3.org/1999/xhtml', 'noscript'): <class 'pyslet.html401.NoScript'>, ('http://www.w3.org/1999/xhtml', 'small'): <class 'pyslet.html401.Small'>, ('http://www.w3.org/1999/xhtml', 'caption'): <class 'pyslet.html401.Caption'>, ('http://www.w3.org/1999/xhtml', 'sup'): <class 'pyslet.html401.Sup'>, ('http://www.w3.org/1999/xhtml', 'big'): <class 'pyslet.html401.Big'>, ('http://www.w3.org/1999/xhtml', 'em'): <class 'pyslet.html401.Em'>, ('http://www.w3.org/1999/xhtml', 'form'): <class 'pyslet.html401.Form'>, ('http://www.w3.org/1999/xhtml', 'meta'): <class 'pyslet.html401.Meta'>, ('http://www.w3.org/1999/xhtml', 'blockquote'): <class 'pyslet.html401.Blockquote'>, ('http://www.w3.org/1999/xhtml', 'a'): <class 'pyslet.html401.A'>, ('http://www.w3.org/1999/xhtml', 'var'): <class 'pyslet.html401.Var'>, ('http://www.w3.org/1999/xhtml', 'legend'): <class 'pyslet.html401.Legend'>, ('http://www.w3.org/1999/xhtml', 'tt'): <class 'pyslet.html401.TT'>, ('http://www.w3.org/1999/xhtml', 'h3'): <class 'pyslet.html401.H3'>, ('http://www.w3.org/1999/xhtml', 'area'): <class 'pyslet.html401.Area'>, ('http://www.w3.org/1999/xhtml', 'tfoot'): <class 'pyslet.html401.TFoot'>, ('http://www.w3.org/1999/xhtml', 'script'): <class 'pyslet.html401.Script'>, ('http://www.w3.org/1999/xhtml', 'center'): <class 'pyslet.html401.Center'>, ('http://www.w3.org/1999/xhtml', 'q'): <class 'pyslet.html401.Q'>, ('http://www.w3.org/1999/xhtml', 'cite'): <class 'pyslet.html401.Cite'>, ('http://www.w3.org/1999/xhtml', 'frame'): <class 'pyslet.html401.Frame'>, ('http://www.w3.org/1999/xhtml', 'address'): <class 'pyslet.html401.Address'>, ('http://www.w3.org/1999/xhtml', 'hr'): <class 'pyslet.html401.HR'>, ('http://www.w3.org/1999/xhtml', 'li'): <class 'pyslet.html401.LI'>, ('http://www.w3.org/1999/xhtml', 'map'): <class 'pyslet.html401.Map'>, ('http://www.w3.org/1999/xhtml', 'h4'): <class 'pyslet.html401.H4'>, ('http://www.w3.org/1999/xhtml', 'td'): <class 'pyslet.html401.TD'>, ('http://www.w3.org/1999/xhtml', 'table'): <class 'pyslet.html401.Table'>, ('http://www.w3.org/1999/xhtml', 'span'): <class 'pyslet.html401.Span'>, ('http://www.w3.org/1999/xhtml', 'ul'): <class 'pyslet.html401.UL'>, ('http://www.w3.org/1999/xhtml', 'head'): <class 'pyslet.html401.Head'>, ('http://www.w3.org/1999/xhtml', 'samp'): <class 'pyslet.html401.Samp'>, ('http://www.w3.org/1999/xhtml', 'tr'): <class 'pyslet.html401.TR'>, ('http://www.w3.org/1999/xhtml', 'sub'): <class 'pyslet.html401.Sub'>, ('http://www.w3.org/1999/xhtml', 's'): <class 'pyslet.html401.S'>, ('http://www.w3.org/1999/xhtml', 'select'): <class 'pyslet.html401.Select'>, ('http://www.w3.org/1999/xhtml', 'col'): <class 'pyslet.html401.Col'>, ('http://www.w3.org/1999/xhtml', 'dd'): <class 'pyslet.html401.DD'>, ('http://www.w3.org/1999/xhtml', 'iframe'): <class 'pyslet.html401.IFrame'>, ('http://www.w3.org/1999/xhtml', 'abbr'): <class 'pyslet.html401.Abbr'>, ('http://www.w3.org/1999/xhtml', 'font'): <class 'pyslet.html401.Font'>, ('http://www.w3.org/1999/xhtml', 'tbody'): <class 'pyslet.html401.TBody'>, ('http://www.w3.org/1999/xhtml', 'img'): <class 'pyslet.html401.Img'>, ('http://www.w3.org/1999/xhtml', 'object'): <class 'pyslet.html401.Object'>, ('http://www.w3.org/1999/xhtml', 'bdo'): <class 'pyslet.html401.BDO'>, ('http://www.w3.org/1999/xhtml', 'body'): <class 'pyslet.html401.Body'>, ('http://www.w3.org/1999/xhtml', 'dt'): <class 'pyslet.html401.DT'>, ('http://www.w3.org/1999/xhtml', 'base'): <class 'pyslet.html401.Base'>, ('http://www.w3.org/1999/xhtml', 'th'): <class 'pyslet.html401.TH'>, ('http://www.w3.org/1999/xhtml', 'label'): <class 'pyslet.html401.Label'>, ('http://www.w3.org/1999/xhtml', 'textarea'): <class 'pyslet.html401.TextArea'>, ('http://www.w3.org/1999/xhtml', 'dfn'): <class 'pyslet.html401.Dfn'>, ('http://www.w3.org/1999/xhtml', 'button'): <class 'pyslet.html401.Button'>, ('http://www.w3.org/1999/xhtml', 'ol'): <class 'pyslet.html401.OL'>, ('http://www.w3.org/1999/xhtml', 'h5'): <class 'pyslet.html401.H5'>, ('http://www.w3.org/1999/xhtml', 'link'): <class 'pyslet.html401.Link'>, ('http://www.w3.org/1999/xhtml', 'pre'): <class 'pyslet.html401.Pre'>, ('http://www.w3.org/1999/xhtml', 'colgroup'): <class 'pyslet.html401.ColGroup'>, ('http://www.w3.org/1999/xhtml', 'style'): <class 'pyslet.html401.Style'>, ('http://www.w3.org/1999/xhtml', 'div'): <class 'pyslet.html401.Div'>, ('http://www.w3.org/1999/xhtml', 'h6'): <class 'pyslet.html401.H6'>, ('http://www.w3.org/1999/xhtml', 'noframes'): <class 'pyslet.html401.NoFrames'>, ('http://www.w3.org/1999/xhtml', 'i'): <class 'pyslet.html401.I'>, ('http://www.w3.org/1999/xhtml', 'title'): <class 'pyslet.html401.Title'>, ('http://www.w3.org/1999/xhtml', 'code'): <class 'pyslet.html401.Code'>, ('http://www.w3.org/1999/xhtml', 'del'): <class 'pyslet.html401.Del'>, ('http://www.w3.org/1999/xhtml', 'kbd'): <class 'pyslet.html401.Kbd'>, ('http://www.w3.org/1999/xhtml', 'html'): <class 'pyslet.html401.HTML'>, ('http://www.w3.org/1999/xhtml', 'option'): <class 'pyslet.html401.Option'>, ('http://www.w3.org/1999/xhtml', 'p'): <class 'pyslet.html401.P'>, ('http://www.w3.org/1999/xhtml', 'h1'): <class 'pyslet.html401.H1'>, ('http://www.w3.org/1999/xhtml', 'b'): <class 'pyslet.html401.B'>}

Data member used to store a mapping from element names to the classes used to represent them. This mapping is initialized when the module is loaded.

default_ns = 'http://www.w3.org/1999/xhtml'

the default namespace for HTML elements

XMLParser(entity)

Create a parser suitable for parsing HTML

We override the basic XML parser to use a custom parser that is intelligent about the use of omitted tags, elements defined to have CDATA content and other SGML-based variations. If the document starts with an XML declaration then the normal XML parser is used instead.

You won’t normally need to call this method as it is invoked automatically when you call pyslet.xml.Document.read().

The result is always a proper element hierarchy rooted in an HTML node, even if no tags are present at all the parser will construct an HTML document containing a single Div element to hold the parsed text.

Because HTML 4 is an application of SGML, rather than XML, we need to modify the basic XML parser to support the parsing of HTML documents. This class is used automatically when reading an XHTMLDocument instance from an entity with declared type that is anything other than text/xml.

class pyslet.html401.HTMLParser(entity=None, **kws)

Bases: pyslet.xml.namespace.XMLNSParser

Custom HTML parser

This variation on the base pyslet.xml.namespace.XMLNSParser does not have to be customised much. Most of the hard work is done by the existing mechanisms for inferring missing tags.

lookup_predefined_entity(name)

Supports HTML entity references

XML includes only a small number of basic entity references to allow the most basic encoding of documents, for example &lt;, &amp;, and so on.

HTML supports a much larger set of character entity references: https://www.w3.org/TR/html401/sgml/entities.html

parse_prolog()

Custom prolog parsing.

We override this method to enable us to dynamically set the parser options based on the presence of an XML declaration or DOCTYPE.

6.3.1.1. Strict DTD

The strict DTD describes the subset of HTML that is more compatible with future versions and generally does not include handling of styling directly but encourages the use of external style sheets.

The public ID to use in the declaration of an HTML document:

pyslet.html401.HTML40_PUBLICID

The system ID to use in the declaration of an HTML document:

pyslet.html401.HTML40_TRANSITIONAL_SYSTEMID

6.3.1.2. Transitional DTD

The transitional DTD, often referred to as the loose DTD contains additional elements and attribute to support backward compatibility. Although this module has been designed to support the the full set of HTML elements attributes that are deprecated and only appear in the loose DTD are not generally mapped to instance attributes in the corresponding classes and where content models differ the classes may enforce (of infer) the stricter model. In particular, there are a number of element that may support both inline and block elements in the loose DTD but which are restricted to block elements in the strict DTD. On reading such a document an implied Div will be used to wrap the inline elements automatically.

The public ID for transitional documents:

pyslet.html401.HTML40_TRANSITIONAL_PUBLICID

The system ID to use in the declaration of transitional documents:

pyslet.html401.HTML40_TRANSITIONAL_SYSTEMID

It should be noted that it is customary to use the strict DTD in the prolog of most HTML documents as this signals to the rendering agent that the document adheres closely to the specification and generally improves the appearance on web pages. However, IFRAMEs are a popular feature of HTML that require use of the transitional DTD. In practice, most content authors ignore this distinction.

6.3.1.3. Frameset DTD

Although rarely used, there is a third form of HTML in which the body of the document is replaced by a frameset.

The public ID for frameset documents:

pyslet.html401.HTML40_FRAMESET_PUBLICID

The system ID to use in the declaration of frameset documents:

pyslet.html401.HTML40_FRAMESET_SYSTEMID

6.3.2. (X)HTML Elements

All HTML elements are based on the XHTMLElement class. In general, elements have their HTML-declared attributes mapped to similarly names attributes of the instance. A number of special purposes types are defined to assist with attribute value validation making it easier to reuse these concepts in other modules. See Basic Types for more information.

class pyslet.html401.XHTMLMixin

Bases: object

An abstract class representing all HTML-like elements.

This class is used to determine if an element should be treated as if it is HTML-like or if it is simply a foreign element from some unknown schema.

HTML-like elements are subject to appropriate HTML content constraints, for example, block elements are not allowed to appear where inline elements are required. Non-HTML-like elements are permitted more freely.

class pyslet.html401.XHTMLElement(parent, name=None)

Bases: pyslet.html401.XHTMLMixin, pyslet.xml.namespace.NSElement

A base class for XHTML elements.

check_model(child_class)

Checks the validity of adding a child element

child_class
The class of an element to be tested

If an instance of child_class would cause a model violation then XHTMLValidityError is raised. This logic is factored into its own method to allow it to be used by add_child() and get_child_class(), both of which may need to make a determination of the legality of adding a child (in the latter case to determine if an element’s end tag has been omitted).

The default implementation checks the rules for the inclusion of the Ins and Del elements to prevent nesting and to ensure that they only appear within a Body instance.

It checks that a form does not appear within another form.

It also checks that the NOFRAMES element in a frameset document is not being nested.

Generally speaking, derived classes add to this implemenation with element-specific rules based on the element’s content model and do not need to override the add_child().

add_child(child_class, name=None)

Overridden to call check_model()

add_to_cpresource(cp, resource, been_there)

See pyslet.imsqtiv2p1.QTIElement.add_to_cpresource()

render_html(parent, profile, arg)

Renders this HTML element to an external document

parent
The parent node to attach a copy of this data too.
profile
A dictionary mapping the names of allowed HTML elements to a list of allowed attributes. This allows the caller to filter out unwanted elements and attributes on a whitelist basis. Warning: this argument is deprecated.
arg
Allows an additional positional argument to be passed through the HTML tree to any non-HTML nodes contained by it. Warning: this argument is deprecated.

The default implementation creates a node under parent if our name is in the profile.

RenderHTML(*args, **kwargs)

Deprecated equivalent to render_html()

RenderText(*args, **kwargs)

Deprecated equivalent to plain_text()

6.3.3. Basic Types

The HTML DTD defines parameter entities to make the intention of each attribute declaration clearer. Theses definitions are often translated into the similarly named classes enabling improved validation of attribute values. The special purpose types also make it easier to parse and format information from and to attribute values.

A special note is required for attributes defined using a form like this:

option     (option)      #IMPLIED

These are mapped to the boolean value True or the value None (or False) indicating an absence of the option. The HTML parser allows the SGML markup minimisation feature so these values can be parsed from attribute definitions such as:

<INPUT disabled name="fred" value="stone">

All attributes of this form are based on the following abstract class.

class pyslet.html401.NamedBoolean

Bases: pyslet.pep8.MigratedClass

An abstract class for named booleans

This class is designed to make generating SGML-like single-value enumeration types easier, for example, attributes such as “checked” on <input>.

The class is not designed to be instantiated but to act as a method of defining functions for decoding and encoding attribute values.

The basic usage of this class is to derive a class from it with a single class member called ‘name’ which is the canonical representation of the name. You can then use it to call any of the following class methods to convert values between python Booleans and the appropriate string representations (None for False and the defined name for True).

classmethod from_str(src)

Decodes a string

Returning True if it matches the name attribute and raises ValueError otherwise. If src is None then False is returned.

classmethod from_str_lower(src)

Decodes a string, converting it to lower case first.

classmethod from_str_upper(src)

Decodes a string, converting it to upper case first.

classmethod to_str(value)

Encodes a named boolean value

Returns either the defined name or None.

classmethod DecodeLowerValue(*args, **kwargs)

Deprecated equivalent to from_str_lower()

classmethod DecodeUpperValue(*args, **kwargs)

Deprecated equivalent to from_str_upper()

classmethod DecodeValue(*args, **kwargs)

Deprecated equivalent to from_str()

classmethod EncodeValue(*args, **kwargs)

Deprecated equivalent to to_str()

XML attributes generally use space separation for multiple values. In HTML there are a number of attributes that use comma-separation. For convenience that attributes are represented using a special purpose tuple-like class.

class pyslet.html401.CommaList(src)

Bases: pyslet.py2.UnicodeMixin

A tuple-like list of strings

Values can be compared with each other for equality, and with strings though the order of items is important. They can be indexed, iterated and supports the in operator for value testing.

6.3.3.1. Align

Attributes defined:

<!ENTITY % align "align (left|center|right|justify)  #IMPLIED"
    -- default is left for ltr paragraphs, right for rtl --"""

may be represented using the following class. These attributes are limited to the loose DTD and this class is not used by any of the element classes defined here. It is provided for convenience only.

class pyslet.html401.Align

Bases: pyslet.xml.xsdatatypes.Enumeration

6.3.3.2. Button type

The Button element defines a type attribute:

type   (button|submit|reset)   submit  -- for use as form button --
class pyslet.html401.ButtonType

Bases: pyslet.xml.xsdatatypes.Enumeration

Enumeration used for the types allowed for Button

ButtonType.DEFAULT == ButtonType.submit

6.3.3.3. CDATA

Attributes defined to have CDATA are represented as character strings or, where space separate values are indicated, lists of character strings.

6.3.3.4. Character

Attributes defined to have type %Character:

<!ENTITY % Character "CDATA" -- a single character from [ISO10646] -->

are parsed using the following function:

..  autofunc:: character_from_str

6.3.3.5. Charset

Atributes defined to have type %Charset or %Charsets:

<!ENTITY % Charset "CDATA" -- a character encoding, as per [RFC2045] -->
<!ENTITY % Charsets "CDATA"
    -- a space-separated list of character encodings, as per [RFC2045] -->

are left as character strings or lists of character strings respectively.

6.3.3.6. Checked

The Input element defines:

checked     (checked)   #IMPLIED    -- for radio buttons and check boxes --
class pyslet.html401.Checked

Bases: pyslet.html401.NamedBoolean

6.3.3.7. Clear

In the loose DTD the Br element defines:

clear       (left|all|right|none)   none    -- control of text flow --

The following class is provided as a convenience and is not used in the implementation of the class.

class pyslet.html401.Clear

Bases: pyslet.xml.xsdatatypes.Enumeration

6.3.3.8. Color

class pyslet.html401.Color(src)

Bases: pyslet.py2.UnicodeMixin

Class to represent a color value

<!ENTITY % Color "CDATA"
    -- a color using sRGB: #RRGGBB as Hex values -->

Instances can be created using either a string or a 3-tuple of sRGB values. The string is either in the #xxxxxx format for hex sRGB values or it one of the “16 widely known color names” which are matched case insentiviely. The canonical representation used when converting back to a character string is the #xxxxxx form.

Color instances can be compared for equality with each other and with characcter string and are hashable but are not sortable.

For convenience, the standard colors are provided as module-level constants.

As a convenience, pre-instantiated color constants are defined that resolve to pre-initialised instances.

pyslet.html401.BLACK
pyslet.html401.GREEN
pyslet.html401.SILVER
pyslet.html401.LIME
pyslet.html401.GRAY
pyslet.html401.OLIVE
pyslet.html401.WHITE
pyslet.html401.YELLOW
pyslet.html401.MAROON
pyslet.html401.NAVY
pyslet.html401.RED
pyslet.html401.BLUE
pyslet.html401.PURPLE
pyslet.html401.TEAL
pyslet.html401.FUCHSIA
pyslet.html401.AQUA

6.3.3.9. ContentType

Attributes defined to have type %ContentType or %ContenTypes:

<!ENTITY % ContentType "CDATA" -- media type, as per [RFC2045] --
<!ENTITY % ContentTypes "CDATA"
    -- comma-separated list of media types, as per [RFC2045]    -->     """

are represented using instances of pyslet.http.params.MediaType. The HTTP header convention of comma-separation is used for multiple values (space being a valid character inside a content type with parameters). These are represented using the tuple-like class:

class pyslet.html401.ContentTypes(src)

Bases: pyslet.py2.UnicodeMixin

A tuple-like list of pyslet.http.params.MediaType.

Values can be compared with each other for equality, and with strings though the order of items is important. They can be indexed, iterated and supports the in operator for value testing.

6.3.3.10. Coordinate Values

Coordinate values are simple lists of Lengths. In most cases Pyslet doesn’t define special types for lists of basic types but coordinates are represented in attribute values using comma separation, not space-separation. As a result they require special processing in order to be decoded/encoded correctly from/to XML streams.

class pyslet.html401.Coords(values=())

Bases: pyslet.py2.UnicodeMixin

Represents HTML Coords values

<!ENTITY % Coords "CDATA" -- comma-separated list of lengths -->

Instances can be initialized from an iterable of Length instances or any object that can be used to construct a Length.

The resulting object behaves like a tuple of Length instances, for example:

x=Coords("10, 50, 60%,75%")
len(x) == 4
str(x[3]) == "75%"

It supports conversion to string and can be compared with a string directly or with a list or tuple of Length values.

values = None

a list of Length values

classmethod from_str(src)

Returns a new instance parsed from a string.

The string must be formatted as per the HTML attribute definition, using comma-separation of values.

test_rect(x, y, width, height)

Tests an x,y point against a rect with these coordinates.

HTML defines the rect co-ordinates as: left-x, top-y, right-x, bottom-y

test_circle(x, y, width, height)

Tests an x,y point against a circle with these coordinates.

HTML defines a circle as: center-x, center-y, radius.

The specification adds the following note:

When the radius value is a percentage value, user agents should calculate the final radius value based on the associated object’s width and height. The radius should be the smaller value of the two.
test_poly(x, y, width, height)

Tests an x,y point against a poly with these coordinates.

HTML defines a poly as: x1, y1, x2, y2, …, xN, yN.

The specification adds the following note:

The first x and y coordinate pair and the last should be the same to close the polygon. When these coordinate values are not the same, user agents should infer an additional coordinate pair to close the polygon.

The algorithm used is the “Ray Casting” algorithm described here: http://en.wikipedia.org/wiki/Point_in_polygon

The Coords class strays slightly into the territory of a rendering agent by providing co-ordinate testing methods. There is no intention to extend this module to support HTML rendering, this functionality is provided to support the server-side evaluation functions in the IMS QTI response processing model.

6.3.3.11. Declare

class pyslet.html401.Declare

Bases: pyslet.html401.NamedBoolean

Used for the declare attribute of Object.

6.3.3.12. Defer

class pyslet.html401.Defer

Bases: pyslet.html401.NamedBoolean

Used for the defer attribute of Script.

6.3.3.13. Direction

Attributes defined to have type (ltr|rtl) are represented using integer constants from the following Enumeration.

class pyslet.html401.Direction

Bases: pyslet.xml.xsdatatypes.Enumeration

Enumeration for weak/neutral text values.

6.3.3.14. Disabled

class pyslet.html401.Disabled

Bases: pyslet.html401.NamedBoolean

Used for the disabled attribute of form controls.

6.3.3.15. Horizontal Cell Alignment

Attributes defined:

align       (left|center|right|justify|char)    #IMPLIED

are used in table structures for cell alignment.

class pyslet.html401.HAlign

Bases: pyslet.xml.xsdatatypes.Enumeration

Values horizontal table cell alignment

6.3.3.16. Image Alignment

The loose DTD supports alignment of images through IAlign:

<!ENTITY % IAlign "(top|middle|bottom|left|right)" -- center? -->"""

This class is provided as a convenience and is not used by the classes in this module.

class pyslet.html401.IAlign

Bases: pyslet.xml.xsdatatypes.Enumeration

6.3.3.17. InputType

The Input class defines a type attribute based on the following definition (though we prefer lower-case for better XML compatibility):

<!ENTITY % InputType    "(TEXT | PASSWORD | CHECKBOX | RADIO |
    SUBMIT | RESET | FILE | HIDDEN | IMAGE | BUTTON)"   >
class pyslet.html401.InputType

Bases: pyslet.xml.xsdatatypes.Enumeration

The type of widget needed for an input element

InputType.DEFAULT == InputType.text

6.3.3.18. Disabled

class pyslet.html401.IsMap

Bases: pyslet.html401.NamedBoolean

Used for the ismap attribute.

6.3.3.19. LanguageCodes

Attributes defined to have type %LanguageCode:

<!ENTITY % LanguageCode "NAME" -- a language code, as per [RFC1766] -->

are represented as character strings using the functions name_from_str() and name_to_str().

6.3.3.20. Length Values

Attributes defined to have type %Length:

<!ENTITY % Length "CDATA"
    -- nn for pixels or nn% for percentage length -->

are represented using instances of the following class.

class pyslet.html401.Length(value, value_type=None, **kws)

Bases: pyslet.py2.UnicodeMixin, pyslet.pep8.MigratedClass

Represents the HTML Length in pixels or as a percentage

value
Can be either an integer value or another Length instance.
value_type (defaults to None)
if value is an integer then value_type may be used to select a PIXEL or PERCENTAGE using the data constants defined below. If value is a string then value_type argument is ignored as this information is determined by the format defined in the specification (a trailing % indicating a PERCENTAGE).

Instances can be compared for equality but not ordered (as pixels and percentages are on different scales). They do support non-zero test though, with 0% and 0 pixels both evaluating to False.

PIXEL = 0

data constant used to indicate pixel co-ordinates (also available as Pixel for backwards compatibility).

PERCENTAGE = 1

data constant used to indicate relative (percentage) co-ordinates (also available as Percentage for backwards compatibility).

type = None

type is one of the the Length constants: PIXEL or PERCENTAGE

value = None

value is the integer value of the length

classmethod from_str(src)

Returns a new instance parsed from a string

resolve_value(dim=None)

Returns the absolute value of the Length

dim
The size of the dimension used for interpreting percentage values. For example, if dim=640 and the value represents 50% the value 320 will be returned.
add(value)

Adds value to the length.

If value is another Length instance then its value is added to the value of this instances’ value only if the types match. If value is an integer it is assumed to be a value of pixel type - a mismatch raises ValueError.

Add(*args, **kwargs)

Deprecated equivalent to add()

GetValue(*args, **kwargs)

Deprecated equivalent to resolve_value()

6.3.3.21. LinkTypes

Attributes defined to have type %LinkTypes:

<!ENTITY % LinkTypes "CDATA"
    -- space-separated list of link types handled directly -->

are represented as a list of lower-cased strings.

6.3.3.22. MediaDesc

Attributes defined to have type %MediaDesc:

<!ENTITY % MediaDesc "CDATA"
    -- single or comma-separated list of media descriptors  -->

are represented by instancs of the following class.

class pyslet.html401.MediaDesc(value=None)

Bases: pyslet.py2.UnicodeMixin

A set-like list of media for which a linked resource is tailored

value
An iterable (yielding strings)

Values are reduced according to the algorithm described in the specification, so that “print and resolution > 90dpi” becomes “print”. Descriptors are further reduced by making them lower case in keeping with their behaviour in CSS.

Instances support the in operator, equality testing (the order of individual descriptors is ignored) and the boolean & and | operators for intersection and union operations always returning new instances. As a convenience, these binary operators will also work with a string argument which is converted to an instance using from_str().

Instances are canonicalized when converting to string by ASCII sorting.

6.3.3.23. Method

class pyslet.html401.Method

Bases: pyslet.xml.xsdatatypes.Enumeration

HTTP method used to submit a form

Method.DEFAULT == Method.GET

6.3.3.24. MultiLength(s)

class pyslet.html401.MultiLength(value, value_type=None, **kws)

Bases: pyslet.html401.Length

MultiLength type from HTML.

“A relative length has the form “i*”, where “i” is an integer… …The value “*” is equivalent to “1*”:

<!ENTITY % MultiLength  "CDATA"
    -- pixel, percentage, or relative -->

Extends the base class Length.

RELATIVE = 2

data constant used to indicate relative (multilength) co-ordinates

classmethod from_str(src)

Returns a new instance parsed from a string

resolve_value(dim=None, multi_total=0)

Extended to handle relative dimension calculations.

dim:
For relative lengths dim must be the remaining space to be shared after PIXEL and PERCENTAGE lengths have been deducted.
multi_total
The sum of all MultiLength values in the current scope. If omitted (defaults to 0) or if the value passed is less than or equal to the relative value then dim is returned (allocating all remaining space to this multilength value).

The behaviour for PIXEL and PERCENTAGE lengths is unchanged.

classmethod allocate_pixels(dim, lengths)

Allocates pixels amongst multilength values

dim
The total number of pixels available.
lengths
A sequence of MultiLength values.

Returns a list of integer pixel values corresponding to the values in lengths.

class pyslet.html401.MultiLengths(values)

Bases: pyslet.py2.UnicodeMixin

Behaves like a tuple of MultiLengths

<!ENTITY % MultiLengths     "CDATA"
    -- comma-separated list of MultiLength -->

Constructed from an iterable of values that can be passed to MultiLength’s constructor.

6.3.3.25. Multiple

class pyslet.html401.Multiple

Bases: pyslet.html401.NamedBoolean

For setting the multiple attribute of <select>.

6.3.3.26. NoHRef

class pyslet.html401.NoHRef

Bases: pyslet.html401.NamedBoolean

For setting the nohref attribute.

6.3.3.27. NoResize

class pyslet.html401.NoResize

Bases: pyslet.html401.NamedBoolean

For setting the noresize attribute.

6.3.3.28. Param Value Types

class pyslet.html401.ParamValueType

Bases: pyslet.xml.xsdatatypes.Enumeration

Enumeration for the valuetype of object parmeters.

6.3.3.29. ReadOnly

class pyslet.html401.ReadOnly

Bases: pyslet.html401.NamedBoolean

Used for the readonly attribute.

6.3.3.30. Scope

Attributes defined to have type %Scope:

<!ENTITY % Scope "(row|col|rowgroup|colgroup)">

are represented as integer constants from the following enumeration.

class pyslet.html401.Scope

Bases: pyslet.xml.xsdatatypes.Enumeration

Enumeration for the scope of table cells.

6.3.3.31. Script

Attributes defined to have type %Script:

<!ENTITY % Script   "CDATA"         -- script expression -->

are not mapped. You can of course obtain their character string values using get_attribute() and set them using set_attribute().

6.3.3.32. Scrolling

Attributes defined to have type:

scrolling   (yes|no|auto)   auto      -- scrollbar or none --

are represented with:

class pyslet.html401.Scrolling

Bases: pyslet.xml.xsdatatypes.Enumeration

Enumeration for the scrolling of iframes.

6.3.3.33. Selected

class pyslet.html401.Selected

Bases: pyslet.html401.NamedBoolean

Used for the selected attribute of <option>.

6.3.3.34. Shape

class pyslet.html401.Shape

Bases: pyslet.xml.xsdatatypes.Enumeration

Enumeration for the shape of clickable areas

<!ENTITY % Shape "(rect|circle|poly|default)">

6.3.3.35. StyleSheet

Attributes defined to have type %StyleSheet:

<!ENTITY % StyleSheet   "CDATA"         -- style sheet data -->

are left as uninterpreted character strings.

6.3.3.36. Text

Attributes defined to have type %Text:

<!ENTITY % Text "CDATA">

are left as interpreted character strings.

6.3.3.37. TFrame

The definition:

<!ENTITY % TFrame
    "(void|above|below|hsides|lhs|rhs|vsides|box|border)">

is modelled by:

class pyslet.html401.TFrame

Bases: pyslet.xml.xsdatatypes.Enumeration

Enumeration for the framing rules of a table.

6.3.3.38. TRules

The definition:

<!ENTITY % TRules "(none | groups | rows | cols | all)">

is modelled by:

class pyslet.html401.TRules

Bases: pyslet.xml.xsdatatypes.Enumeration

Enumeration for the framing rules of a table.

6.3.3.39. URI

Attributes defined to have type %URI:

<!ENTITY % URI "CDATA"  -- a Uniform Resource Identifier -->

are represented using pyslet.rfc2396.URI. This class automatically handles non-ASCII characters using the algorithm recommended in Appendix B of the specification, which involves replacing them with percent-encoded UTF-sequences.

When serialising these attributes we use the classes native string conversion which results in ASCII characters only so we don’t adhere to the principal of using the ASCII encoding only at the latest possible time.

6.3.3.40. Vertical Cell Alignment

The definition:

<!ENTITY % cellvalign
    "valign     (top|middle|bottom|baseline) #IMPLIED"  >

is modelled by:

class pyslet.html401.VAlign

Bases: pyslet.xml.xsdatatypes.Enumeration

Enumeration for the vertical alignment of table cells

6.3.4. Attribute Mixin Classes

The DTD uses parameter entities to group related attribute definitions for re-use by multiple elements. We define mixin classes for each to group together the corresponding custom attribute mappings.

class pyslet.html401.AlignMixin

Bases: object

Mixin class for (loose) align attributes

<!ENTITY % align "
    align   (left|center|right|justify) #IMPLIED"
        -- default is left for ltr paragraphs, right for rtl --

These attributes are only defined by the loose DTD and are therefore not mapped to attributes of the instance.

class pyslet.html401.BodyColorsMixin

Bases: object

Mixin class for (loose) body color attributes

<!ENTITY % bodycolors
    "bgcolor    %Color;     #IMPLIED  -- document background color --
     text       %Color;     #IMPLIED  -- document text color --
     link       %Color;     #IMPLIED  -- color of links --
     vlink      %Color;     #IMPLIED  -- color of visited links --
     alink      %Color;     #IMPLIED  -- color of selected links --"
    >

These attributes are only defined by the loose DTD and are deprecated, they are therefore not mapped to attributes of the instance.

class pyslet.html401.CellAlignMixin

Bases: object

Mixin class for table cell aignment attributes

<!ENTITY % cellhalign
    "align      (left|center|right|justify|char)    #IMPLIED
     char       %Character;                         #IMPLIED
        -- alignment char, e.g. char=':' --
     charoff    %Length;                            #IMPLIED
        -- offset for alignment char --"
    >

<!ENTITY % cellvalign
    "valign     (top|middle|bottom|baseline)        #IMPLIED">
class pyslet.html401.CoreAttrsMixin

Bases: object

Mixin class for core attributes

<!ENTITY % coreattrs
    "id     ID             #IMPLIED -- document-wide unique id --
     class  CDATA          #IMPLIED -- space-separated list of classes --
     style  %StyleSheet;   #IMPLIED -- associated style info --
     title  %Text;         #IMPLIED -- advisory title --"
    >

The id attribute is declared in the DTD to be of type ID so is mapped to the special unique ID attribute for special handling by Element.

The class attribute is mapped to the python attribute style_class to avoid the python reserved name.

class pyslet.html401.EventsMixin

Bases: object

Mixin class for event attributes

<!ENTITY % events
    "onclick     %Script;   #IMPLIED
        -- a pointer button was clicked --
     ondblclick  %Script;   #IMPLIED
        -- a pointer button was double clicked--
     onmousedown %Script;   #IMPLIED
        -- a pointer button was pressed down --
     onmouseup   %Script;   #IMPLIED
        -- a pointer button was released --
     onmouseover %Script;   #IMPLIED
        -- a pointer was moved onto --
     onmousemove %Script;   #IMPLIED
        -- a pointer was moved within --
     onmouseout  %Script;   #IMPLIED
        -- a pointer was moved away --
     onkeypress  %Script;   #IMPLIED
        -- a key was pressed and released --
     onkeydown   %Script;   #IMPLIED
        -- a key was pressed down --
     onkeyup     %Script;   #IMPLIED
        -- a key was released --"
    >

Pyslet is not an HTML rendering engine and so no attribute mappings are provided for these script hooks. Their values can of course be obtained using the generic get_attribute.

class pyslet.html401.I18nMixin

Bases: object

Mixin class for i18n attributes

<!ENTITY % i18n
    "lang  %LanguageCode; #IMPLIED     -- language code --
     dir   (ltr|rtl)      #IMPLIED
        -- direction for weak/neutral text --">
get_lang()

Replaces access to xml:lang

If an element has set the HTML lang attribute we return this, otherwise we check if the element has set xml:lang and return that instead.

set_lang() is not modified, it always sets the xml:lang attribute.

class pyslet.html401.ReservedMixin

Bases: object

Attributes reserved for future use

<!ENTITY % reserved
    "datasrc        %URI;       #IMPLIED
        -- a single or tabular Data Source --
     datafld        CDATA       #IMPLIED
        -- the property or column name --
     dataformatas   (plaintext|html)    plaintext
        -- text or html --"
    >

As these attributes are reserved for future no mappings are provided.

The following classes extend the above to form established groups.

class pyslet.html401.AttrsMixin

Bases: pyslet.html401.CoreAttrsMixin, pyslet.html401.I18nMixin, pyslet.html401.EventsMixin

Mixin class for common attributes

<!ENTITY % attrs "%coreattrs; %i18n; %events;">
class pyslet.html401.TableCellMixin

Bases: pyslet.html401.CellAlignMixin, pyslet.html401.AttrsMixin

Attributes shared by TD and TH

<!ATTLIST (TH|TD)       -- header or data cell --
    %attrs;         -- %coreattrs, %i18n, %events --
    abbr            %Text;      #IMPLIED
        -- abbreviation for header cell --
    axis            CDATA       #IMPLIED
        -- comma-separated list of related headers--
    headers         IDREFS      #IMPLIED
        -- list of id's for header cells --
    scope           %Scope;     #IMPLIED
        -- scope covered by header cells --
    rowspan         NUMBER      1
        -- number of rows spanned by cell --
    colspan         NUMBER      1
        -- number of cols spanned by cell --
    %cellhalign;    -- horizontal alignment in cells --
    %cellvalign;    -- vertical alignment in cells --
    nowrap          (nowrap)    #IMPLIED
        -- suppress word wrap --
    bgcolor         %Color;     #IMPLIED
        -- cell background color --
    width           %Length;    #IMPLIED
        -- width for cell --
    height          %Length;    #IMPLIED
        -- height for cell --
    >

The nowrap, bgcolor, width and height attributes are only defined in the loose DTD and are not mapped.

6.3.5. Content Mixin Classes

The DTD uses parameter entities to group elements into major roles. The most important roles are block, inline and flow. A block element is something like a paragraph, a list or table. An inline element is something that represents a span of text (including data itself) and a flow refers to either a block or inline. We exploit these definitions to create mixin classes that have no implementation but enable us to use Python issubclass or isinstance to test and enforce the content model. It also enables this model to be extended by external classes that also inherit from these basic classes to declare their role when inserted into HTML documents. This technique is used extensively by IMS QTI where non-HTML markup is intermingled with HTML markup.

class pyslet.html401.FlowMixin

Bases: pyslet.html401.XHTMLMixin

Mixin class for flow elements

<!ENTITY % flow "%block; | %inline;">
class pyslet.html401.BlockMixin

Bases: pyslet.html401.FlowMixin

Mixin class for block elements

<!ENTITY % block "P | %heading; | %list; | %preformatted; | DL | DIV |
    NOSCRIPT | BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">
class pyslet.html401.InlineMixin

Bases: pyslet.html401.FlowMixin

Mixin class for inline elements

<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; |
    %formctrl;">

With these basic three classes we can go on to define a number of derived mixin classes representing the remaining specialised element groupings.

class pyslet.html401.FormCtrlMixin

Bases: pyslet.html401.InlineMixin

Form controls are just another type of inline element

<!ENTITY % formctrl "INPUT | SELECT | TEXTAREA | LABEL | BUTTON">
class pyslet.html401.HeadContentMixin

Bases: object

Mixin class for HEAD content elements

<!ENTITY % head.content     "TITLE & BASE?">
class pyslet.html401.HeadMiscMixin

Bases: object

Mixin class for head.misc elements

<!ENTITY % head.misc    "SCRIPT|STYLE|META|LINK|OBJECT"
    -- repeatable head elements -->
class pyslet.html401.OptItemMixin

Bases: object

Mixin class for (OPTGROUP|OPTION)

class pyslet.html401.PreExclusionMixin

Bases: object

Mixin class for elements excluded from PRE

<!ENTITY % pre.exclusion
    "IMG|OBJECT|APPLET|BIG|SMALL|SUB|SUP|FONT|BASEFONT">
class pyslet.html401.SpecialMixin

Bases: pyslet.html401.InlineMixin

Specials are just another type of inline element.

Strict DTD:

<!ENTITY % special "A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB |
    SUP | SPAN | BDO">

Loose DTD:

<!ENTITY % special "A | IMG | APPLET | OBJECT | FONT | BASEFONT | BR |
    SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO | IFRAME">
class pyslet.html401.TableColMixin

Bases: object

Mixin class for COL | COLGROUP elements.

6.3.6. Abstract Element Classes

Unlike the mixin classes that identify an element as belonging to a group the following abstract classes are used as base classes for implementing the rules of various content models. Just as classes can be inline, block or (rarely just) flow many elements are declared to contain either inline, block or flow children. The following classes are used as the base class in each case.

class pyslet.html401.BlockContainer(parent, name=None)

Bases: pyslet.html401.XHTMLElement

Abstract class for all HTML elements that contain just %block;

We support start-tag omission for inline data or elements by forcing an implied <div>. We also support end-tag omission.

class pyslet.html401.InlineContainer(parent, name=None)

Bases: pyslet.html401.XHTMLElement

Abstract class for elements that contain inline elements

Support end-tag omission.

class pyslet.html401.FlowContainer(parent, name=None)

Bases: pyslet.html401.XHTMLElement

Abstract class for all HTML elements that contain %flow;

We support end tag omission.

can_pretty_print()

Deteremins if this flow-container should be pretty printed.

We suppress pretty printing if we have any non-trivial data children.

The following more specific abstract classes build on the above to implement base classes for elements that are defined together using parameter entities.

class pyslet.html401.FlowContainer(parent, name=None)

Bases: pyslet.html401.XHTMLElement

Abstract class for all HTML elements that contain %flow;

We support end tag omission.

can_pretty_print()

Deteremins if this flow-container should be pretty printed.

We suppress pretty printing if we have any non-trivial data children.

class pyslet.html401.Heading(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.InlineContainer

Abstract class for representing headings

<!ELEMENT (%heading;)   - - (%inline;)* -- heading -->
<!ATTLIST (%heading;)
    %attrs;     -- %coreattrs, %i18n, %events --
    %align;     -- align, text alignment --
    >

The align attribute is unmapped as it is not available in the strict DTD.

class pyslet.html401.InsDelInclusion(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.FlowContainer

Represents inserted or deleted content

<!-- INS/DEL are handled by inclusion on BODY -->
<!ELEMENT (INS|DEL) - - (%flow;)*   -- inserted text, deleted text -->
<!ATTLIST (INS|DEL)
    %attrs;     -- %coreattrs, %i18n, %events --
    cite        %URI;       #IMPLIED  -- info on reason for change --
    datetime    %Datetime;  #IMPLIED  -- date and time of change --
    >

According to the DTD these elements can be inserted at will anywhere inside the document body (except that they do not appear within their own content models so do not nest). However, the specification suggests that they are actually to be treated as satisfying either block or inline which suggests that the intention is not to allow them to be inserted randomly in elements with more complex structures such as lists and tables. Indeed, there is the additional constraint that an inclusion appearing in an inline context may not contain block-level elements.

We don’t allow omitted end tags (as that seems dangerous) so incorrectly nested instances or block/inline misuse will cause validity exceptions. E.g.:

<body>
    <p>Welcome
    <ins><p>This document is about...</ins>
</body>

triggers an exception because <ins> is permitted in <p> but takes on an inline role. <p> is therefore not allowed in <ins> but the end tag of </ins> is required, triggering an error. This seems harsh given (a) that the markup is compatibile with the DTD and (b) the meaning seems clear but I can only reiterate Goldfarb’s words from the SGML handbook where he says of exceptions:

Like many good power tools, however, if used improperly they can cause significant damage
class pyslet.html401.Phrase(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.InlineMixin, pyslet.html401.InlineContainer

Abstract class for phrase elements

<!ENTITY % phrase "EM | STRONG | DFN | CODE | SAMP | KBD | VAR |
    CITE | ABBR | ACRONYM" >
<!ELEMENT (%fontstyle;|%phrase;) - - (%inline;)*>
<!ATTLIST (%fontstyle;|%phrase;)
    %attrs;         -- %coreattrs, %i18n, %events --
    >

6.3.6.1. Lists

class pyslet.html401.List(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.XHTMLElement

Abstract class for representing list elements

<!ENTITY % list "UL | OL">

Although a list item start tag is compulsory we are generous and will imply a list item if data is found. The end tag of the list is required.

6.3.6.2. Tables

class pyslet.html401.TRContainer(parent, name=None)

Bases: pyslet.html401.XHTMLElement

get_child_class(stag_class)

PCDATA or TH|TD trigger TR, end tags may be omitted

6.3.6.3. Frames

The content model of FRAMESET allows either (nested) FRAMESET or FRAME elements. The following class acts as both base class and as a way to identify the members of this group.

class pyslet.html401.FrameElement(parent, name=None)

Bases: pyslet.html401.CoreAttrsMixin, pyslet.html401.XHTMLElement

6.3.7. Element Reference

The classes that model each HTML element are documented here in alphabetical order for completeness.

class pyslet.html401.A(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.SpecialMixin, pyslet.html401.InlineContainer

The HTML anchor element

<!ELEMENT A - - (%inline;)* -(A)       -- anchor -->
<!ATTLIST A
    %attrs;     -- %coreattrs, %i18n, %events --
    charset     %Charset;       #IMPLIED
        -- char encoding of linked resource --
    type        %ContentType;   #IMPLIED
        -- advisory content type --
    name        CDATA           #IMPLIED
        -- named link end --
    href        %URI;           #IMPLIED
        -- URI for linked resource --
    hreflang    %LanguageCode;  #IMPLIED
        -- language code --
    target      %FrameTarget;   #IMPLIED
        -- render in this frame --
    rel         %LinkTypes;     #IMPLIED
        -- forward link types --
    rev         %LinkTypes;     #IMPLIED
        -- reverse link types --
    accesskey   %Character;     #IMPLIED
        -- accessibility key character --
    shape       %Shape;         rect
        -- for use with client-side image maps --
    coords      %Coords;        #IMPLIED
        -- for use with client-side image maps --
    tabindex    NUMBER          #IMPLIED
        -- position in tabbing order --
    onfocus     %Script;        #IMPLIED
        -- the element got the focus --
    onblur      %Script;        #IMPLIED
        -- the element lost the focus -->

The event hander attributes are not mapped but the target is, even though it is only defined in the loose DTD. Note that, despite the default value given in the DTD the shape attribute is not set and it will only have a non-None value in an instance if a value was provided explicitly.

class pyslet.html401.Abbr(parent, name=None)

Bases: pyslet.html401.Phrase

class pyslet.html401.Address(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.InlineContainer

Address (of author)

<!ELEMENT ADDRESS - - ((%inline;)|P)*  -- information on author -->
<!ATTLIST ADDRESS
    %attrs;     -- %coreattrs, %i18n, %events --
    >
class pyslet.html401.Area(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.XHTMLElement

Client-side image map area

<!ELEMENT AREA - O EMPTY        -- client-side image map area -->
<!ATTLIST AREA
    %attrs;     -- %coreattrs, %i18n, %events --
    shape       %Shape;         rect
        -- controls interpretation of coords --
    coords      %Coords;        #IMPLIED
        -- comma-separated list of lengths --
    href        %URI;           #IMPLIED
        -- URI for linked resource --
    target      %FrameTarget;   #IMPLIED
        -- render in this frame --
    nohref      (nohref)        #IMPLIED
        -- this region has no action --
    alt         %Text;          #REQUIRED   -- short description --
    tabindex    NUMBER          #IMPLIED
        -- position in tabbing order --
    accesskey   %Character;     #IMPLIED
        -- accessibility key character --
    onfocus     %Script;        #IMPLIED
        -- the element got the focus --
    onblur      %Script;        #IMPLIED
        -- the element lost the focus --
    >

The event attributes are not mapped however the target attribute is, even though it relates on to frames and the loose DTD.

class pyslet.html401.B(parent, name=None)

Bases: pyslet.html401.FontStyle

class pyslet.html401.Base(parent, name=None)

Bases: pyslet.html401.HeadContentMixin, pyslet.html401.XHTMLElement

Represents the base element

<!ELEMENT BASE - O EMPTY        -- document base URI -->
<!ATTLIST BASE
    href    %URI;   #REQUIRED   -- URI that acts as base URI --
    >
class pyslet.html401.BaseFont(parent)

Bases: pyslet.html401.PreExclusionMixin, pyslet.html401.SpecialMixin, pyslet.html401.XHTMLElement

Deprecated base font specification

<!ELEMENT BASEFONT - O EMPTY           -- base font size -->
<!ATTLIST BASEFONT
    id      ID          #IMPLIED    -- document-wide unique id --
    size    CDATA       #REQUIRED
        -- base font size for FONT elements --
    color   %Color;     #IMPLIED    -- text color --
    face    CDATA       #IMPLIED
        -- comma-separated list of font names -->
class pyslet.html401.BDO(parent)

Bases: pyslet.html401.CoreAttrsMixin, pyslet.html401.SpecialMixin, pyslet.html401.InlineContainer

BiDi over-ride element

<!ELEMENT BDO - - (%inline;)*          -- I18N BiDi over-ride -->
<!ATTLIST BDO
    %coreattrs;     -- id, class, style, title --
    lang            %LanguageCode;  #IMPLIED    -- language code --
    dir             (ltr|rtl)       #REQUIRED   -- directionality --
    >

The dir attribute is initialised to the Direction constant ltr.

class pyslet.html401.Big(parent, name=None)

Bases: pyslet.html401.PreExclusionMixin, pyslet.html401.FontStyle

class pyslet.html401.Blockquote(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.BlockContainer

Blocked quote.

Strict DTD:

<!ELEMENT BLOCKQUOTE - - (%block;|SCRIPT)+ -- long quotation -->

Loost DTD:

<!ELEMENT BLOCKQUOTE - - (%flow;)*     -- long quotation -->

This implementation enforces the strict DTD by wrapping data and inline content in DIV. The Attributes are common to both forms of the DTD:

<!ATTLIST BLOCKQUOTE
    %attrs;     -- %coreattrs, %i18n, %events --
    cite        %URI;   #IMPLIED
        -- URI for source document or msg -->
class pyslet.html401.Body(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BodyColorsMixin, pyslet.html401.BlockContainer

Represents the HTML BODY element

<!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body -->
<!ATTLIST BODY
    %attrs;         -- %coreattrs, %i18n, %events --
    onload          %Script;    #IMPLIED
        -- the document has been loaded --
    onunload        %Script;    #IMPLIED
        -- the document has been removed --
    background      %URI;       #IMPLIED
        -- texture tile for document background --
    %bodycolors;    -- bgcolor, text, link, vlink, alink --
    >

Note that the event handlers are not mapped to instance attributes.

class pyslet.html401.Br(parent, name=None)

Bases: pyslet.html401.CoreAttrsMixin, pyslet.html401.SpecialMixin, pyslet.html401.XHTMLElement

Represents a line break

<!ELEMENT BR - O EMPTY                 -- forced line break -->
<!ATTLIST BR
    %coreattrs;     -- id, class, style, title --
    clear           (left|all|right|none)   none
        -- control of text flow -->

The clear attribute is only in the loose DTD and is not mapped.

class pyslet.html401.Button(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.ReservedMixin, pyslet.html401.FormCtrlMixin, pyslet.html401.FlowContainer

Alternative form of button (with content)

<!ELEMENT BUTTON - - (%flow;)* -(A|%formctrl;|FORM|FIELDSET)
    -- push button -->
<!ATTLIST BUTTON
    %attrs;     -- %coreattrs, %i18n, %events --
    name        CDATA                       #IMPLIED
    value       CDATA                       #IMPLIED
        -- sent to server when submitted --
    type        (button|submit|reset)       submit
        -- for use as form button --
    disabled    (disabled)                  #IMPLIED
        -- unavailable in this context --
    tabindex    NUMBER                      #IMPLIED
        -- position in tabbing order --
    accesskey   %Character;                 #IMPLIED
        -- accessibility key character --
    onfocus     %Script;                    #IMPLIED
        -- the element got the focus --
    onblur      %Script;                    #IMPLIED
        -- the element lost the focus --
    %reserved;  -- reserved for possible future use -->

The event handlers are not mapped.
class pyslet.html401.Caption(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.InlineContainer

Represents a table caption

<!ELEMENT CAPTION  - - (%inline;)*     -- table caption -->
<!ATTLIST CAPTION
    %attrs;     -- %coreattrs, %i18n, %events --
    align       %CAlign;        #IMPLIED  -- relative to table --
    >

The align attribute is along defiend in the loose DTD and is not mapped.

class pyslet.html401.Center(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.FlowContainer

Equivalent to <div align=”center”>, only applies to loose DTD

<!ELEMENT CENTER - - (%flow;)*  -- shorthand for DIV align=center -->
<!ATTLIST CENTER
    %attrs;                     -- %coreattrs, %i18n, %events --
    >
class pyslet.html401.Cite(parent, name=None)

Bases: pyslet.html401.Phrase

class pyslet.html401.Code(parent, name=None)

Bases: pyslet.html401.Phrase

class pyslet.html401.Col(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.CellAlignMixin, pyslet.html401.TableColMixin, pyslet.html401.XHTMLElement

Represents a table column

<!ELEMENT COL       - O EMPTY   -- table column -->
<!ATTLIST COL                   -- column groups and properties --
    %attrs;         -- %coreattrs, %i18n, %events --
    span            NUMBER          1
        -- COL attributes affect N columns --
    width           %MultiLength;   #IMPLIED
        -- column width specification --
    %cellhalign;    -- horizontal alignment in cells --
    %cellvalign;        -- vertical alignment in cells --
    >
class pyslet.html401.ColGroup(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.CellAlignMixin, pyslet.html401.TableColMixin, pyslet.html401.XHTMLElement

Represents a group of columns

<!ELEMENT COLGROUP - O (COL)*          -- table column group -->
<!ATTLIST COLGROUP
    %attrs;         -- %coreattrs, %i18n, %events --
    span            NUMBER          1
        -- default number of columns in group --
    width           %MultiLength;   #IMPLIED
        -- default width for enclosed COLs --
    %cellhalign;    -- horizontal alignment in cells --
    %cellvalign;    -- vertical alignment in cells --
    >
class pyslet.html401.DD(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.FlowContainer

Represents the definition of a defined term

<!ELEMENT DD - O (%flow;)*      -- definition description -->
<!ATTLIST (DT|DD)
    %attrs;         -- %coreattrs, %i18n, %events --
    >
class pyslet.html401.Del(parent, name=None)

Bases: pyslet.html401.InsDelInclusion

class pyslet.html401.Dfn(parent, name=None)

Bases: pyslet.html401.Phrase

class pyslet.html401.Div(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.ReservedMixin, pyslet.html401.BlockMixin, pyslet.html401.FlowContainer

A generic flow container

<!ELEMENT DIV - -  (%flow;)*            --  -->
<!ATTLIST DIV
    %attrs;         -- %coreattrs, %i18n, %events --
    %align;         -- align, text alignment --
    %reserved;      -- reserved for possible future use --
    >
class pyslet.html401.DL(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.XHTMLElement

Represents definition lists

<!ELEMENT DL - - (DT|DD)+              -- definition list -->
<!ATTLIST DL
    %attrs;     -- %coreattrs, %i18n, %events --
    compact     (compact)   #IMPLIED    -- reduced interitem spacing --
    >

The compact attribute is not mapped as it is only defined in the loose DTD.

class pyslet.html401.DT(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.InlineContainer

Represents a defined term

<!ELEMENT DT - O (%inline;)*    -- definition term -->
<!ATTLIST (DT|DD)
    %attrs;     -- %coreattrs, %i18n, %events -->
class pyslet.html401.Em(parent, name=None)

Bases: pyslet.html401.Phrase

class pyslet.html401.FieldSet(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.FlowContainer

Represents a group of controls in a form

<!ELEMENT FIELDSET - -  (#PCDATA,LEGEND,(%flow;)*)
    -- form control group -->
<!ATTLIST FIELDSET
    %attrs;     -- %coreattrs, %i18n, %events -->
class pyslet.html401.Font(parent, name=None)

Bases: pyslet.html401.I18nMixin, pyslet.html401.CoreAttrsMixin, pyslet.html401.SpecialMixin, pyslet.html401.InlineContainer

Represents font style information (loose DTD only)

<!ELEMENT FONT - - (%inline;)*         -- local change to font -->
<!ATTLIST FONT
    %coreattrs;     -- id, class, style, title --
    %i18n;          -- lang, dir --
    size            CDATA       #IMPLIED
        -- [+|-]nn e.g. size="+1", size="4" --
    color           %Color;     #IMPLIED
        -- text color --
    face            CDATA       #IMPLIED
        -- comma-separated list of font names -->

Although defined only in the loose DTD we provide custom mappings for all of the attributes.

class pyslet.html401.Form(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.BlockContainer

Represents the form element.

Strict DTD:

<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->

Loose DTD:

<!ELEMENT FORM - - (%flow;)* -(FORM)   -- interactive form -->

Attributes (target is mapped even though it is only in the loose DTD) as it is for use in frame-based documents:

<!ATTLIST FORM
    %attrs;     -- %coreattrs, %i18n, %events --
    action      %URI;           #REQUIRED
        -- server-side form handler --
    method      (GET|POST)      GET
        -- HTTP method used to submit the form--
    enctype     %ContentType;   "application/x-www-form-urlencoded"
    accept      %ContentTypes;  #IMPLIED
        -- list of MIME types for file upload --
    name        CDATA           #IMPLIED
        -- name of form for scripting --
    onsubmit    %Script;        #IMPLIED
        -- the form was submitted --
    onreset     %Script;        #IMPLIED    -- the form was reset --
    target      %FrameTarget;   #IMPLIED    -- render in this frame --
    accept-charset %Charsets;   #IMPLIED
        -- list of supported charsets --
    >
class pyslet.html401.Frame(parent)

Bases: pyslet.html401.FrameElement

Represents a Frame within a frameset document

<!ELEMENT FRAME - O EMPTY              -- subwindow -->
<!ATTLIST FRAME
    %coreattrs;     -- id, class, style, title --
    longdesc        %URI;           #IMPLIED
         -- link to long description (complements title) --
    name            CDATA           #IMPLIED
        -- name of frame for targetting --
    src             %URI;           #IMPLIED
        -- source of frame content --
    frameborder     (1|0)           1
        -- request frame borders? --
    marginwidth     %Pixels;        #IMPLIED
        -- margin widths in pixels --
    marginheight    %Pixels;        #IMPLIED
        -- margin height in pixels --
    noresize        (noresize)      #IMPLIED
        -- allow users to resize frames? --
    scrolling       (yes|no|auto)   auto
        -- scrollbar or none -->

The frameborder, marginwidth and marginheight attributes are not mapped.

class pyslet.html401.Frameset(parent)

Bases: pyslet.html401.FrameElement

Represents a frameset (within a Frameset document)

<!ELEMENT FRAMESET - - ((FRAMESET|FRAME)+ & NOFRAMES?)
    -- window subdivision-->
<!ATTLIST FRAMESET
    %coreattrs;     -- id, class, style, title --
    rows            %MultiLengths;  #IMPLIED
        -- list of lengths, default: 100% (1 row) --
    cols            %MultiLengths;  #IMPLIED
        -- list of lengths, default: 100% (1 col) --
    onload          %Script;        #IMPLIED
        -- all the frames have been loaded  --
    onunload        %Script;        #IMPLIED
        -- all the frames have been removed --
    >

The event handlers are not mapped to custom attributes.

class pyslet.html401.H1(parent, name=None)

Bases: pyslet.html401.Heading

class pyslet.html401.H2(parent, name=None)

Bases: pyslet.html401.Heading

class pyslet.html401.H3(parent, name=None)

Bases: pyslet.html401.Heading

class pyslet.html401.H4(parent, name=None)

Bases: pyslet.html401.Heading

class pyslet.html401.H5(parent, name=None)

Bases: pyslet.html401.Heading

class pyslet.html401.H6(parent, name=None)

Bases: pyslet.html401.Heading

class pyslet.html401.Head(parent)

Bases: pyslet.html401.I18nMixin, pyslet.html401.XHTMLElement

Represents the HTML head structure

<!ELEMENT HEAD O O (%head.content;) +(%head.misc;)
    -- document head -->
<!ATTLIST HEAD
    %i18n;      -- lang, dir --
    profile   %URI;   #IMPLIED
        -- named dictionary of meta info --
      >
class pyslet.html401.HR(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.XHTMLElement

Represents a horizontal rule

<!ELEMENT HR - O EMPTY -- horizontal rule -->
<!ATTLIST HR
    %attrs;     -- %coreattrs, %i18n, %events --
    align       (left|center|right)     #IMPLIED
    noshade     (noshade)               #IMPLIED
    size        %Pixels;                #IMPLIED
    width       %Length;                #IMPLIED
    >

The align, noshade, size and width attributes are not defined in the strict DTD and are not mapped.

class pyslet.html401.HTML(parent)

Bases: pyslet.html401.I18nMixin, pyslet.html401.XHTMLElement

Represents the HTML document strucuture

<!ENTITY % html.content "HEAD, BODY">

<!ELEMENT HTML O O (%html.content;)     -- document root element -->
<!ATTLIST HTML
      %i18n;                            -- lang, dir --
>
class pyslet.html401.HTMLFrameset(parent)

Bases: pyslet.html401.I18nMixin, pyslet.html401.XHTMLElement

Represents the HTML frameset document element

<!ENTITY % html.content "HEAD, FRAMESET">

See HTML for a complete declaration.

We omit the default name declaration XMLNAME to ensure uniqueness in the document mapping adding. When creating orphan instances of this element you must use set_xmlname() to set a name for the element before serialization.

class pyslet.html401.I(parent, name=None)

Bases: pyslet.html401.FontStyle

class pyslet.html401.IFrame(parent)

Bases: pyslet.html401.CoreAttrsMixin, pyslet.html401.SpecialMixin, pyslet.html401.FlowContainer

Represents the iframe element

<!ELEMENT IFRAME - - (%flow;)*         -- inline subwindow -->
<!ATTLIST IFRAME
    %coreattrs;                          -- id, class, style, title --
    longdesc    %URI;          #IMPLIED
        -- link to long description (complements title) --
    name            CDATA           #IMPLIED
        -- name of frame for targetting --
    src             %URI;           #IMPLIED
        -- source of frame content --
    frameborder     (1|0)           1
        -- request frame borders? --
    marginwidth     %Pixels;        #IMPLIED
        -- margin widths in pixels --
    marginheight    %Pixels;        #IMPLIED
        -- margin height in pixels --
    scrolling       (yes|no|auto)   auto
        -- scrollbar or none --
    align           %IAlign;        #IMPLIED
        -- vertical or horizontal alignment --
    height          %Length;        #IMPLIED    -- frame height --
    width           %Length;        #IMPLIED    -- frame width --
    >

IFrames are not part of the strict DTD, perhaps surprisingly given their widespread adoption. For consistency with other elements we leave the frameborder, marginwidth, marginheight and align attrbutes unmapped. As a result, we rely on the default frameborder value provided in the DTD rather than setting an attribute explicitly on construction. In contrast, the scrolling attribute is mapped and is initialised to Scrolling.auto.

class pyslet.html401.Img(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.PreExclusionMixin, pyslet.html401.SpecialMixin, pyslet.html401.XHTMLElement

Represents the <img> element

<!ELEMENT IMG - O EMPTY                -- Embedded image -->
<!ATTLIST IMG
    %attrs;     -- %coreattrs, %i18n, %events --
    src         %URI;       #REQUIRED   -- URI of image to embed --
    alt         %Text;      #REQUIRED   -- short description --
    longdesc    %URI;       #IMPLIED
        -- link to long description (complements alt) --
    name        CDATA       #IMPLIED
        -- name of image for scripting --
    height      %Length;    #IMPLIED    -- override height --
    width       %Length;    #IMPLIED    -- override width --
    usemap      %URI;       #IMPLIED
        -- use client-side image map --
    ismap       (ismap)     #IMPLIED
        -- use server-side image map --
    align       %IAlign;    #IMPLIED
        -- vertical or horizontal alignment --
    border      %Pixels;    #IMPLIED    -- link border width --
    hspace      %Pixels;    #IMPLIED    -- horizontal gutter --
    vspace      %Pixels;    #IMPLIED    -- vertical gutter --
    >

The align, border, hspace and vspace attributes are only defined by the loose DTD are are no mapped.

class pyslet.html401.Input(parent)

Bases: pyslet.html401.FormCtrlMixin, pyslet.html401.AttrsMixin, pyslet.html401.XHTMLElement

Represents the input element

<!-- attribute name required for all but submit and reset -->
<!ELEMENT INPUT - O EMPTY              -- form control -->
<!ATTLIST INPUT
    %attrs;     -- %coreattrs, %i18n, %events --
    type        %InputType;     TEXT
        -- what kind of widget is needed --
    name        CDATA           #IMPLIED
        -- submit as part of form --
    value       CDATA           #IMPLIED
        -- Specify for radio buttons and checkboxes --
    checked     (checked)       #IMPLIED
        -- for radio buttons and check boxes --
    disabled    (disabled)      #IMPLIED
        -- unavailable in this context --
    readonly    (readonly)      #IMPLIED
        -- for text and passwd --
    size        CDATA           #IMPLIED
        -- specific to each type of field --
    maxlength   NUMBER          #IMPLIED
        -- max chars for text fields --
    src         %URI;           #IMPLIED
        -- for fields with images --
    alt         CDATA           #IMPLIED
        -- short description --
    usemap      %URI;           #IMPLIED
        -- use client-side image map --
    ismap       (ismap)         #IMPLIED
        -- use server-side image map --
    tabindex    NUMBER          #IMPLIED
        -- position in tabbing order --
    accesskey   %Character;     #IMPLIED
        -- accessibility key character --
    onfocus     %Script;        #IMPLIED
        -- the element got the focus --
    onblur      %Script;        #IMPLIED
        -- the element lost the focus --
    onselect    %Script;        #IMPLIED
        -- some text was selected --
    onchange    %Script;        #IMPLIED
        -- the element value was changed --
    accept      %ContentTypes;  #IMPLIED
        -- list of MIME types for file upload --
    align       %IAlign;        #IMPLIED
        -- vertical or horizontal alignment --
    %reserved;  -- reserved for possible future use --
    >

The event handlers are unmapped. The align attribute is defined only in the loose DTD and is also unmapped.

class pyslet.html401.Ins(parent, name=None)

Bases: pyslet.html401.InsDelInclusion

class pyslet.html401.IsIndex(parent, name=None)

Bases: pyslet.html401.CoreAttrsMixin, pyslet.html401.I18nMixin, pyslet.html401.HeadContentMixin, pyslet.html401.BlockMixin, pyslet.html401.XHTMLElement

Deprecated one-element form control

<!ELEMENT ISINDEX - O EMPTY            -- single line prompt -->
<!ATTLIST ISINDEX
    %coreattrs;     -- id, class, style, title --
    %i18n;          -- lang, dir --
    prompt          %Text;  #IMPLIED    -- prompt message -->
class pyslet.html401.Kbd(parent, name=None)

Bases: pyslet.html401.Phrase

class pyslet.html401.Label(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.FormCtrlMixin, pyslet.html401.InlineContainer

Label element

<!ELEMENT LABEL - - (%inline;)* -(LABEL) -- form field label text -->
<!ATTLIST LABEL
    %attrs;     -- %coreattrs, %i18n, %events --
    for         IDREF           #IMPLIED
        -- matches field ID value --
    accesskey   %Character;     #IMPLIED
        -- accessibility key character --
    onfocus     %Script;        #IMPLIED
        -- the element got the focus --
    onblur      %Script;        #IMPLIED
        -- the element lost the focus -->

To avoid the use of the reserved word ‘for’ this attribute is mapped to the attribute name for_field. The event attributes are not mapped.

class pyslet.html401.Legend(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.InlineContainer

legend element

<!ELEMENT LEGEND - - (%inline;)*       -- fieldset legend -->

<!ATTLIST LEGEND
  %attrs;                              -- %coreattrs, %i18n, %events --
  accesskey   %Character;    #IMPLIED  -- accessibility key character --
  >
class pyslet.html401.LI(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.FlowContainer

Represent list items

<!ELEMENT LI - O (%flow;)*             -- list item -->
<!ATTLIST LI
    %attrs;     -- %coreattrs, %i18n, %events --
    type        %LIStyle;   #IMPLIED  -- list item style --
    value       NUMBER      #IMPLIED  -- reset sequence number -->

The type and value attributes are only defined by the loose DTD and are not mapped.

Bases: pyslet.html401.AttrsMixin, pyslet.html401.HeadMiscMixin, pyslet.html401.XHTMLElement

Media-independent link

<!ELEMENT LINK - O EMPTY               -- a media-independent link -->
<!ATTLIST LINK
    %attrs;                              -- %coreattrs, %i18n, %events --
    charset     %Charset;      #IMPLIED
        -- char encoding of linked resource --
    href        %URI;          #IMPLIED  -- URI for linked resource --
    hreflang    %LanguageCode; #IMPLIED  -- language code --
    type        %ContentType;  #IMPLIED  -- advisory content type --
    rel         %LinkTypes;    #IMPLIED  -- forward link types --
    rev         %LinkTypes;    #IMPLIED  -- reverse link types --
    media       %MediaDesc;    #IMPLIED  -- for rendering on these media --
    >
class pyslet.html401.Map(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.SpecialMixin, pyslet.html401.BlockContainer

Represents a client-side image map

<!ELEMENT MAP - - ((%block;) | AREA)+ -- client-side image map -->
<!ATTLIST MAP
    %attrs;     -- %coreattrs, %i18n, %events --
    name        CDATA   #REQUIRED -- for reference by usemap --
    >
class pyslet.html401.Meta(parent)

Bases: pyslet.html401.I18nMixin, pyslet.html401.HeadMiscMixin, pyslet.html401.XHTMLElement

Represents the meta element

<!ELEMENT META - O EMPTY                -- generic metainformation -->
<!ATTLIST META
  %i18n;        -- lang, dir, for use with content --
  http-equiv    NAME        #IMPLIED    -- HTTP response header name  --
  name          NAME        #IMPLIED    -- metainformation name --
  content       CDATA       #REQUIRED   -- associated information --
  scheme        CDATA       #IMPLIED    -- select form of content --
  >

The http-equiv attribute cannot be mapped

class pyslet.html401.NoFrames(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.FlowContainer

Represents the NOFRAMES element.

This element is deprecated, it is not part of the strict DTD or HTML5. This element is used to represent instances encountered in documents using the loose DTD:

<!ENTITY % noframes.content "(%flow;)*">

<!ELEMENT NOFRAMES - - %noframes.content;
    -- alternate content container for non frame-based rendering -->
<!ATTLIST NOFRAMES
    %attrs;         -- %coreattrs, %i18n, %events -->
class pyslet.html401.NoFramesFrameset(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.XHTMLElement

Represents the NOFRAMES element in a FRAMESET document.

This element is deprecated, it is not part of the strict DTD or HTML5. This element is used to represent instances encountered in documents using the frameset DTD:

<!ENTITY % noframes.content "(BODY) -(NOFRAMES)">

<!ATTLIST NOFRAMES
    %attrs;         -- %coreattrs, %i18n, %events -->

We omit the XMLNAME attribute (the default element name) to prevent a name clash when declaring the elements in the name space. Instead we’ll use a special catch to ensure that <noframes> maps to this element in a frameset context.

class pyslet.html401.NoScript(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.BlockContainer

Represents the NOSCRIPT element

Loose DTD:

<!ELEMENT NOSCRIPT - - (%flow;)*
    -- alternate content container for non script-based rendering -->

Strict DTD:

<!ELEMENT NOSCRIPT - - (%block;)+
    -- alternate content container for non script-based rendering -->

Common:

<!ATTLIST NOSCRIPT
    %attrs;     -- %coreattrs, %i18n, %events -->

We take the liberty of enforcing the stricter DTD which has the effect of starting an implicit <div> if inline elements are encountered in <noscript> elements.

We also bring forward an element of HTML5 compatibility by allowing NoScript within the document <head> with a content model equivalent to:

<!ELEMENT NOSCRIPT - - (LINK|STYLE|META)*   -->
class pyslet.html401.Object(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.ReservedMixin, pyslet.html401.SpecialMixin, pyslet.html401.HeadMiscMixin, pyslet.html401.FlowContainer

Represents the object element

<!ELEMENT OBJECT    - - (PARAM | %flow;)*

<!ATTLIST OBJECT
    %attrs;     -- %coreattrs, %i18n, %events --
    declare   (declare)         #IMPLIED
        -- declare but don't instantiate flag --
    classid     %URI;           #IMPLIED
        -- identifies an implementation --
    codebase    %URI;           #IMPLIED
        -- base URI for classid, data, archive--
    data        %URI;           #IMPLIED
        -- reference to object's data --
    type        %ContentType;   #IMPLIED
        -- content type for data --
    codetype    %ContentType;   #IMPLIED
        -- content type for code --
    archive     CDATA           #IMPLIED
        -- space-separated list of URIs --
    standby     %Text;          #IMPLIED
        -- message to show while loading --
    height      %Length;        #IMPLIED    -- override height --
    width       %Length;        #IMPLIED    -- override width --
    usemap      %URI;           #IMPLIED
        -- use client-side image map --
    name        CDATA           #IMPLIED
        -- submit as part of form --
    tabindex    NUMBER          #IMPLIED
        -- position in tabbing order --
    %reserved;  -- reserved for possible future use --
    >
class pyslet.html401.OL(parent, name=None)

Bases: pyslet.html401.List

Represents ordered lists

<!ELEMENT OL - - (LI)+                 -- ordered list -->
<!ATTLIST OL
    %attrs;     -- %coreattrs, %i18n, %events --
    type        %OLStyle;   #IMPLIED  -- numbering style --
    compact     (compact)   #IMPLIED  -- reduced interitem spacing --
    start       NUMBER      #IMPLIED  -- starting sequence number --
    >

The type, compact and start attributes are only defined in the loose DTD and so are not mapped.

class pyslet.html401.OptGroup(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.OptItemMixin, pyslet.html401.XHTMLElement

OptGroup element

<!ELEMENT OPTGROUP - - (OPTION)+ -- option group -->
<!ATTLIST OPTGROUP
    %attrs;     -- %coreattrs, %i18n, %events --
    disabled    (disabled)      #IMPLIED
        -- unavailable in this context --
    label       %Text;          #REQUIRED
        -- for use in hierarchical menus --
    >
class pyslet.html401.Option(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.OptItemMixin, pyslet.html401.XHTMLElement

Option element

<!ELEMENT OPTION - O (#PCDATA)         -- selectable choice -->
<!ATTLIST OPTION
    %attrs;     -- %coreattrs, %i18n, %events --
    selected    (selected)      #IMPLIED
    disabled    (disabled)      #IMPLIED
        -- unavailable in this context --
    label       %Text;          #IMPLIED
        -- for use in hierarchical menus --
    value       CDATA           #IMPLIED
        -- defaults to element content --
    >
class pyslet.html401.P(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.AlignMixin, pyslet.html401.BlockMixin, pyslet.html401.InlineContainer

Represents a paragraph

<!ELEMENT P - O (%inline;)*     -- paragraph -->
<!ATTLIST P
    %attrs;     -- %coreattrs, %i18n, %events --
    %align;     -- align, text alignment --
    >
class pyslet.html401.Param(parent)

Bases: pyslet.html401.XHTMLElement

Represents an object parameter

<!ELEMENT PARAM - O EMPTY           -- named property value -->
<!ATTLIST PARAM
    id          ID                  #IMPLIED
        -- document-wide unique id --
    name        CDATA               #REQUIRED
        -- property name --
    value       CDATA               #IMPLIED
        -- property value --
    valuetype   (DATA|REF|OBJECT)   DATA
        -- How to interpret value --
    type        %ContentType;       #IMPLIED
        -- content type for value when valuetype=ref --
    >

The name attribute is required and is initialised to “_”. The valuetype attribute is not populated automatically so applications processing this element should treat a value of None as equivalent to the integer constant ParamValueType.data. The value of value is always a string, even if valuetype is ref, indicating that it should be interpreted as a URI.

class pyslet.html401.Pre(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.BlockMixin, pyslet.html401.InlineContainer

Represents pre-formatted text

<!ELEMENT PRE - - (%inline;)* -(%pre.exclusion;)
    -- preformatted text -->
<!ATTLIST PRE
    %attrs;     -- %coreattrs, %i18n, %events --
    width       NUMBER      #IMPLIED
    >

The width attribute is only defined in the loose DTD and is not mapped.

class pyslet.html401.Q(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.SpecialMixin, pyslet.html401.InlineContainer

Represents an inline quotation

<!ELEMENT Q - - (%inline;)*     -- short inline quotation -->
<!ATTLIST Q
    %attrs;     -- %coreattrs, %i18n, %events --
    cite        %URI;   #IMPLIED  -- URI for source document or msg --
    >
class pyslet.html401.S(parent, name=None)

Bases: pyslet.html401.FontStyle

class pyslet.html401.Samp(parent, name=None)

Bases: pyslet.html401.Phrase

class pyslet.html401.Script(parent)

Bases: pyslet.html401.SpecialMixin, pyslet.html401.HeadMiscMixin, pyslet.html401.XHTMLElement

Represents the script element

<!ELEMENT SCRIPT    - - %Script;    -- script statements -->
<!ATTLIST SCRIPT
    charset %Charset;      #IMPLIED
        -- char encoding of linked resource --
    type    %ContentType;  #REQUIRED
        -- content type of script language --
    src     %URI;          #IMPLIED
        -- URI for an external script --
    defer   (defer)        #IMPLIED
        -- UA may defer execution of script --
    event   CDATA          #IMPLIED
        -- reserved for possible future use --
    for     %URI;          #IMPLIED
        -- reserved for possible future use -->

As the type is required isntances are initialised with text/javascript.

class pyslet.html401.Select(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.FormCtrlMixin, pyslet.html401.XHTMLElement

Select element

<!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector -->
<!ATTLIST SELECT
    %attrs;     -- %coreattrs, %i18n, %events --
    name        CDATA       #IMPLIED  -- field name --
    size        NUMBER      #IMPLIED  -- rows visible --
    multiple    (multiple)  #IMPLIED  -- default is single selection --
    disabled    (disabled)  #IMPLIED  -- unavailable in this context --
    tabindex    NUMBER      #IMPLIED  -- position in tabbing order --
    onfocus     %Script;    #IMPLIED  -- the element got the focus --
    onblur      %Script;    #IMPLIED  -- the element lost the focus --
    onchange    %Script;    #IMPLIED  -- the element value was changed --
    %reserved;  -- reserved for possible future use --
    >

No custom mapping is provided for the event handlers.

class pyslet.html401.Small(parent, name=None)

Bases: pyslet.html401.PreExclusionMixin, pyslet.html401.FontStyle

class pyslet.html401.Span(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.SpecialMixin, pyslet.html401.InlineContainer

Represents a span of text

<!ELEMENT SPAN - - (%inline;)*
    -- generic language/style container -->
<!ATTLIST SPAN
    %attrs;         -- %coreattrs, %i18n, %events --
    %reserved;      -- reserved for possible future use --
    >
class pyslet.html401.Strike(parent, name=None)

Bases: pyslet.html401.FontStyle

class pyslet.html401.Strong(parent, name=None)

Bases: pyslet.html401.Phrase

class pyslet.html401.Style(parent)

Bases: pyslet.html401.I18nMixin, pyslet.html401.HeadMiscMixin, pyslet.html401.XHTMLElement

Represents the style element

<!ELEMENT STYLE     - - %StyleSheet     -- style info -->
<!ATTLIST STYLE
    %i18n;      -- lang, dir, for use with title --
    type        %ContentType;  #REQUIRED
        -- content type of style language --
    media       %MediaDesc;    #IMPLIED
        -- designed for use with these media --
    title       %Text;         #IMPLIED
        -- advisory title --
    >

As the content type is required instances are initialised with text/css.

class pyslet.html401.Sub(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.PreExclusionMixin, pyslet.html401.SpecialMixin, pyslet.html401.InlineContainer

Represents a subscript

<!ELEMENT (SUB|SUP) - - (%inline;)*    -- subscript, superscript -->
<!ATTLIST (SUB|SUP)     %attrs;     -- %coreattrs, %i18n, %events -->
class pyslet.html401.Sup(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.PreExclusionMixin, pyslet.html401.SpecialMixin, pyslet.html401.InlineContainer

Represents a superscript

<!ELEMENT (SUB|SUP) - - (%inline;)*    -- subscript, superscript -->
<!ATTLIST (SUB|SUP)     %attrs;     -- %coreattrs, %i18n, %events -->
class pyslet.html401.Table(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.ReservedMixin, pyslet.html401.BlockMixin, pyslet.html401.XHTMLElement

Represents a table

<!ELEMENT TABLE - - (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?,
                     TBODY+)>
<!ATTLIST TABLE                 -- table element --
    %attrs;         -- %coreattrs, %i18n, %events --
    summary         %Text;      #IMPLIED
        -- purpose/structure for speech output--
    width           %Length;    #IMPLIED
        -- table width --
    border          %Pixels;    #IMPLIED
        -- controls frame width around table --
    frame           %TFrame;    #IMPLIED
        -- which parts of frame to render --
    rules           %TRules;    #IMPLIED
        -- rulings between rows and cols --
    cellspacing     %Length;    #IMPLIED
        -- spacing between cells --
    cellpadding     %Length;    #IMPLIED
        -- spacing within cells --
    align           %TAlign;    #IMPLIED
        -- table position relative to window --
    bgcolor         %Color;     #IMPLIED
        -- background color for cells --
    %reserved;      -- reserved for possible future use --
    datapagesize    CDATA       #IMPLIED
        -- reserved for possible future use --
    >

The align and bgcolor attributes are only defined in the loose DTD and are not mapped. The datapagesize is also not mapped.

When parsing we are generous in allowing data to automatically start the corresponding TBody (and hence TR+TD).

class pyslet.html401.TBody(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.CellAlignMixin, pyslet.html401.TRContainer

Represents a table body

<!ELEMENT TBODY    O O (TR)+           -- table body -->
<!ATTLIST (THEAD|TBODY|TFOOT)       -- table section --
    %attrs;         -- %coreattrs, %i18n, %events --
    %cellhalign;    -- horizontal alignment in cells --
    %cellvalign;    -- vertical alignment in cells --
    >

This is an unusual element as it is rarely seen in HTML because both start and end tags can be omitted. However, it appears as a required part of TABLE’s content model so will always be present if any TR elements are present (unless they are contained in in THEAD or TFOOT).

class pyslet.html401.TD(parent, name=None)

Bases: pyslet.html401.TableCellMixin, pyslet.html401.FlowContainer

Represents a table cell

<!ELEMENT (TH|TD)  - O (%flow;)*
    -- table header cell, table data cell-->

For attribute information see TableCellMixin.

class pyslet.html401.TextArea(parent)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.ReservedMixin, pyslet.html401.FormCtrlMixin, pyslet.html401.XHTMLElement

TextArea element

<!ELEMENT TEXTAREA - - (#PCDATA)       -- multi-line text field -->
<!ATTLIST TEXTAREA
  %attrs;                              -- %coreattrs, %i18n, %events --
  name        CDATA          #IMPLIED
  rows        NUMBER         #REQUIRED
  cols        NUMBER         #REQUIRED
  disabled    (disabled)     #IMPLIED  -- unavailable in this context --
  readonly    (readonly)     #IMPLIED
  tabindex    NUMBER         #IMPLIED  -- position in tabbing order --
  accesskey   %Character;    #IMPLIED  -- accessibility key character --
  onfocus     %Script;       #IMPLIED  -- the element got the focus --
  onblur      %Script;       #IMPLIED  -- the element lost the focus --
  onselect    %Script;       #IMPLIED  -- some text was selected --
  onchange    %Script;       #IMPLIED  -- the element value was changed --
  %reserved;    -- reserved for possible future use --
  >

The event handlers are not mapped. As rows and cols are both required the constructor provides initial values of 1 and 80 respectively.

class pyslet.html401.TFoot(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.CellAlignMixin, pyslet.html401.TRContainer

Represents a table footer

<!ELEMENT TFOOT    - O (TR)+        -- table footer -->
<!ATTLIST (THEAD|TBODY|TFOOT)       -- table section --
    %attrs;         -- %coreattrs, %i18n, %events --
    %cellhalign;    -- horizontal alignment in cells --
    %cellvalign;    -- vertical alignment in cells --
    >
class pyslet.html401.TH(parent, name=None)

Bases: pyslet.html401.TableCellMixin, pyslet.html401.FlowContainer

Represents a table header cell

<!ELEMENT (TH|TD)  - O (%flow;)*
    -- table header cell, table data cell-->

For attribute information see TableCellMixin.

class pyslet.html401.THead(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.CellAlignMixin, pyslet.html401.TRContainer

Represents a table header

<!ELEMENT THEAD    - O (TR)+        -- table header -->
<!ATTLIST (THEAD|TBODY|TFOOT)       -- table section --
    %attrs;         -- %coreattrs, %i18n, %events --
    %cellhalign;    -- horizontal alignment in cells --
    %cellvalign;    -- vertical alignment in cells --
    >
class pyslet.html401.Title(parent, name=None)

Bases: pyslet.html401.I18nMixin, pyslet.html401.HeadContentMixin, pyslet.html401.XHTMLElement

Represents the TITLE element

<!ELEMENT TITLE - - (#PCDATA) -(%head.misc;) -- document title -->
<!ATTLIST TITLE %i18n   >
class pyslet.html401.TR(parent, name=None)

Bases: pyslet.html401.AttrsMixin, pyslet.html401.CellAlignMixin, pyslet.html401.XHTMLElement

Represents a table row

<!ELEMENT TR    - O (TH|TD)+        -- table row -->
<!ATTLIST TR        -- table row --
    %attrs;         -- %coreattrs, %i18n, %events --
    %cellhalign;    -- horizontal alignment in cells --
    %cellvalign;    -- vertical alignment in cells --
    bgcolor     %Color;     #IMPLIED
        -- background color for row --
    >

The bgcolor attribute is only defined by the loose DTD so is left unmapped. We treat data inside <tr> as starting an implicit <td> element.

class pyslet.html401.TT(parent, name=None)

Bases: pyslet.html401.FontStyle

class pyslet.html401.U(parent, name=None)

Bases: pyslet.html401.FontStyle

class pyslet.html401.UL(parent, name=None)

Bases: pyslet.html401.List

Represents the unordered list element

<!ELEMENT UL - - (LI)+      -- ordered list -->
<!ATTLIST UL
    %attrs;     -- %coreattrs, %i18n, %events --
    type        %ULStyle;   #IMPLIED    -- bullet style --
    compact     (compact)   #IMPLIED
        -- reduced interitem spacing --
    >

The type and compact attributes are only defined by the loose DTD and are left unmapped.

class pyslet.html401.Var(parent, name=None)

Bases: pyslet.html401.Phrase

6.3.8. Exceptions

class pyslet.html401.XHTMLError

Bases: exceptions.Exception

Abstract base class for errors in this module

class pyslet.html401.XHTMLValidityError

Bases: pyslet.html401.XHTMLError

General error raised by HTML model constraints.

The parser is very generous in attempting to interpret HTML but there some situations where it would be dangerous to infer the intent and this error is raised in those circumstances.

class pyslet.html401.XHTMLError

Bases: exceptions.Exception

Abstract base class for errors in this module