Package docutils :: Module nodes :: Class Element
[frames | no frames]

Class Element

Node --+
       |
      Element

Known Subclasses:
XmlFragment, XpathReference

Element is the superclass to all specific elements.

Elements contain attributes and child nodes. Elements emulate dictionaries for attributes, indexing by attribute name (a string). To set the attribute 'att' to 'value', do:

element['att'] = 'value'

There are two special attributes: 'ids' and 'names'. Both are lists of unique identifiers, and names serve as human interfaces to IDs. Names are case- and whitespace-normalized (see the fully_normalize_name() function), and IDs conform to the regular expression [a-z](-?[a-z0-9]+)* (see the make_id() function).

Elements also emulate lists for child nodes (element nodes and/or text nodes), indexing by integer. To get the first child node, use:

element[0]

Elements may be constructed using the += operator. To add one new child node to element, do:

element += node

This is equivalent to element.append(node).

To add a list of multiple child nodes at once, use the same += operator:

element += [node1, node2]

This is equivalent to element.extend([node1, node2]).


Method Summary
  __init__(self, rawsource, *children, **attributes)
  __add__(self, other)
  __delitem__(self, key)
  __getitem__(self, key)
  __iadd__(self, other)
Append a node or a list of nodes to self.children.
  __len__(self)
  __radd__(self, other)
  __repr__(self)
  __setitem__(self, key, item)
  __str__(self)
  __unicode__(self)
  append(self, item)
  astext(self)
  attlist(self)
  clear(self)
  copy(self)
Return a copy of self.
  deepcopy(self)
Return a deep copy of self (also copying children).
  delattr(self, attr)
  emptytag(self)
  endtag(self)
  extend(self, item)
  first_child_matching_class(self, childclass, start, end)
Return the index of the first child whose class exactly matches.
  first_child_not_matching_class(self, childclass, start, end)
Return the index of the first child whose class does not match.
  get(self, key, failobj)
  has_key(self, attr)
  hasattr(self, attr)
  index(self, item)
  insert(self, index, item)
  is_not_default(self, key)
  non_default_attributes(self)
  note_referenced_by(self, name, id)
Note that this Element has been referenced by its name name or id id.
  pformat(self, indent, level)
Return an indented pseudo-XML representation, for test purposes.
  pop(self, i)
  remove(self, item)
  replace(self, old, new)
Replace one child Node with another child or children.
  replace_self(self, new)
Replace self node with new, where new is a node or a list of nodes.
  set_class(self, name)
Add a new class to the "classes" attribute.
  setdefault(self, key, failobj)
  shortrepr(self)
  starttag(self)
  update_basic_atts(self, dict)
Update basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') from node or dictionary dict.
    Inherited from Node
  __nonzero__(self)
Node instances are always true, even if they're empty.
  asdom(self, dom)
Return a DOM fragment representation of this Node.
  next_node(self, condition, include_self, descend, siblings, ascend)
Return the first node in the iterable returned by traverse(), or None if the iterable is empty.
  setup_child(self, child)
  traverse(self, condition, include_self, descend, siblings, ascend)
Return an iterable containing
  walk(self, visitor)
Traverse a tree of Node objects, calling the dispatch_visit() method of visitor when entering each node.
  walkabout(self, visitor)
Perform a tree traversal similarly to Node.walk() (which see), except also call the dispatch_departure() method before exiting each node.

Class Variable Summary
str child_text_separator = '\n\n'
tuple list_attributes = ('ids', 'classes', 'names', 'dupnames'...
NoneType tagname = None                                                                  
    Inherited from Node
NoneType document = None                                                                  
NoneType line = None                                                                  
NoneType parent = None                                                                  
NoneType source = None                                                                  

Method Details

__iadd__(self, other)

Append a node or a list of nodes to self.children.

copy(self)

Return a copy of self.

Overrides:
docutils.nodes.Node.copy (inherited documentation)

deepcopy(self)

Return a deep copy of self (also copying children).

Overrides:
docutils.nodes.Node.deepcopy (inherited documentation)

first_child_matching_class(self, childclass, start=0, end=2147483647)

Return the index of the first child whose class exactly matches.

Parameters:

  • childclass: A Node subclass to search for, or a tuple of Node classes. If a tuple, any of the classes may match.
  • start: Initial index to check.
  • end: Initial index to not check.

first_child_not_matching_class(self, childclass, start=0, end=2147483647)

Return the index of the first child whose class does not match.

Parameters:

  • childclass: A Node subclass to skip, or a tuple of Node classes. If a tuple, none of the classes may match.
  • start: Initial index to check.
  • end: Initial index to not check.

note_referenced_by(self, name=None, id=None)

Note that this Element has been referenced by its name name or id id.

pformat(self, indent='    ', level=0)

Return an indented pseudo-XML representation, for test purposes.

Override in subclasses.

Overrides:
docutils.nodes.Node.pformat (inherited documentation)

replace(self, old, new)

Replace one child Node with another child or children.

replace_self(self, new)

Replace self node with new, where new is a node or a list of nodes.

set_class(self, name)

Add a new class to the "classes" attribute.

update_basic_atts(self, dict)

Update basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') from node or dictionary dict.


Class Variable Details

child_text_separator

Type:
str
Value:
'''

'''                                                                    

list_attributes

Type:
tuple
Value:
('ids', 'classes', 'names', 'dupnames', 'backrefs')                    

tagname

Type:
NoneType
Value:
None                                                                  

Generated by Epydoc 2.1 on Wed Jul 12 11:20:41 2006 http://epydoc.sf.net