Package translate :: Package storage :: Module dtd

[hide private]
[frames] | no frames]

# Module dtd

source code

classes that hold units of .dtd files (dtdunit) or entire files (dtdfile) these are specific .dtd files for localisation used by mozilla

# Specifications

The following information is provided by Mozilla:

* Specification

There is a grammar for entity definitions, which isn't really precise, as the spec says. There's no formal specification for DTD files, it's just "whatever makes this work" basically. The whole piece is clearly not the strongest point of the xml spec

XML elements are allowed in entity values. A number of things that are allowed will just break the resulting document, Mozilla forbids these in their DTD parser.

Classes | [hide private]

| dtdunit this class represents an entity definition from a dtd file (and possibly associated comments)
| dtdfile this class represents a .dtd file, made up of dtdunits

Functions | [hide private]

quotefordtd(source) | source code

unquotefromdtd(source) unquotes a quoted dtd definition | source code

String

removeinvalidamps(name, value) Find and remove ampersands that are not part of an entity definition. | source code

Variables | [hide private]

| labelsuffixes = ``(``'``.label``'``,` `'``.title``'``)`` Label suffixes: entries with this suffix are able to be comibed with accesskeys found in in entries ending with accesskeysuffixes
| accesskeysuffixes = ``(``'``.accesskey``'``,` `'``.accessKey``'``,` `'``.akey``'``)`` Accesskey Suffixes: entries with this suffix may be combined with labels ending in labelsuffixes into accelerator notation

Imports: base, quote, re, warnings, StringIO, etree

Function Details | [hide private]

### removeinvalidamps(name, value)

source code

Find and remove ampersands that are not part of an entity definition.

A stray & in a DTD file can break an applications ability to parse the file. In Mozilla localisation this is very important and these can break the parsing of files used in XUL and thus break interface rendering. Tracking down the problem is very difficult, thus by removing potential broken & and warning the users we can ensure that the output DTD will always be parsable.

Parameters:
  - `name` (String) - Entity name
  - `value` (String) - Entity text value
Returns: String
  Entity value without bad ampersands