Package cssutils :: Package css :: Module csscharsetrule :: Class CSSCharsetRule |
[hide private]
[frames] | no frames]

# Class CSSCharsetRule

source code

     object --+
              |
      util.Base --+
                  |
    cssrule.CSSRule --+
                      |
                     CSSCharsetRule

The CSSCharsetRule interface represents an @charset rule in a CSS style sheet. The value of the encoding attribute does not affect the encoding of text data in the DOM objects; this encoding is always UTF-16 (also in Python?). After a stylesheet is loaded, the value of the encoding attribute is the value found in the @charset rule. If there was no @charset in the original document, then no CSSCharsetRule is created. The value of the encoding attribute may also be used as a hint for the encoding used on serialization of the style sheet.

The value of the @charset rule (and therefore of the CSSCharsetRule) may not correspond to the encoding the document actually came in; character encoding information e.g. in an HTTP header, has priority (see CSS document representation) but this is not reflected in the CSSCharsetRule.

# Properties

cssText: of type DOMString
  The parsable textual representation of this rule
encoding: of type DOMString
  The encoding information used in this @charset rule.

Inherits properties from CSSRule

# Format

charsetrule:
  CHARSET_SYM S* STRING S* ';'
BUT: Only valid format is:
  @charset "ENCODING";

Nested Classes | [hide private]
Inherited from `util.Base` (private): `_prods`

Instance Methods | [hide private]
__init__(self, encoding=None, readonly=False) a valid character encoding | source code
_getEncoding(self) returns encoding as a string | source code
_setEncoding(self, encoding) DOMException on setting | source code
_getCssText(self) returns serialized property cssText | source code
_setCssText(self, cssText) DOMException on setting | source code
__repr__(self) repr(x) | source code
__str__(self) str(x) | source code
Inherited from `cssrule.CSSRule` (private): `_getTypeString` Inherited from `util.Base` (private): `_checkReadonly`, `_getProductions`, `_newseq`, `_nexttoken`, `_parse`, `_tokenize2`, `_tokensupto2`, `_tokenvalue`, `_type`, `_valuestr` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`

Static Methods | [hide private]
Inherited from `util.Base` (private): `_normalize`

Class Variables | [hide private]
| type = `2` The type of this rule, as defined by a CSSRule type constant.
Inherited from `cssrule.CSSRule`: `COMMENT`, `FONT_FACE_RULE`, `UNKNOWN_RULE` Inherited from `cssrule.CSSRule` (private): `_typestrings` Inherited from `util.Base` (private): `_SHORTHANDPROPERTIES`, `_log`

Properties | [hide private]
| encoding (DOM)The encoding information used in this @charset rule.
| cssText (DOM) The parsable textual representation.
Inherited from `cssrule.CSSRule`: `typeString` Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, encoding=None, readonly=False) (Constructor) | source code
encoding: a valid character encoding readonly: defaults to False, not used yet if readonly allows setting of properties in constructor only Overrides: cssrule.CSSRule.__init__

### _setEncoding(self, encoding) | source code
DOMException on setting NO_MODIFICATION_ALLOWED_ERR: (CSSRule) Raised if this encoding rule is readonly. SYNTAX_ERR: (self) Raised if the specified encoding value has a syntax error and is unparsable. Currently only valid Python encodings are allowed.

### _getCssText(self) | source code
returns serialized property cssText Overrides: cssrule.CSSRule._getCssText

### _setCssText(self, cssText) | source code
DOMException on setting SYNTAX_ERR: (self) Raised if the specified CSS string value has a syntax error and is unparsable. INVALID_MODIFICATION_ERR: (self) Raised if the specified CSS string value represents a different type of rule than the current one. HIERARCHY_REQUEST_ERR: (CSSStylesheet) Raised if the rule cannot be inserted at this point in the style sheet. NO_MODIFICATION_ALLOWED_ERR: (CSSRule) Raised if the rule is readonly. Overrides: cssrule.CSSRule._setCssText

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

Property Details | [hide private]

  ### encoding (DOM)The encoding information used in this @charset rule. Get Method: cssutils.css.csscharsetrule.CSSCharsetRule._getEncoding(self) - returns encoding as a string Set Method: cssutils.css.csscharsetrule.CSSCharsetRule._setEncoding(self, encoding) - DOMException on setting Delete Method:
      None

  ### cssText (DOM) The parsable textual representation. Get Method: cssutils.css.csscharsetrule.CSSCharsetRule._getCssText(self) - returns serialized property cssText Set Method: cssutils.css.csscharsetrule.CSSCharsetRule._setCssText(self, cssText) - DOMException on setting Delete Method:
      None