Package glue :: Package ligolw :: Module ligolw :: Class Element
[hide private]
[frames] | no frames]

Class Element

source code

object --+
         |
        Element
Known Subclasses:

Base class for all element types. This class is inspired by the class of the same name in the Python standard library's xml.dom package. One important distinction is that the standard DOM element is used to represent the structure of a document at a much finer level of detail than here. For example, in the case of the standard DOM element, each XML attribute is its own element being a child node of its tag, while here they are simply stored as attributes of the tag element itself.

Despite the differences, the documentation for the xml.dom package, particularly that of the Element class and it's parent, the Node class, is useful as supplementary material in understanding how to use this class.

Instance Methods [hide private]
 
__init__(self, attrs=None)
Construct an element.
source code
 
_verifyChildren(self, i)
Method used internally by some elements to verify that their children are from the allowed set and in the correct order following modifications to their child list.
source code
 
appendChild(self, child)
Add a child to this element.
source code
 
appendData(self, content)
Add characters to the element's pcdata.
source code
 
endElement(self)
Method invoked by document parser when it encounters the end-of-element event.
source code
 
end_tag(self, indent)
Generate the string for the element's end tag.
source code
 
getAttribute(self, attrname) source code
 
getChildrenByAttributes(self, attrs) source code
 
getElements(self, filter)
Return a list of elements below and including this element for which filter(element) returns True.
source code
 
getElementsByTagName(self, tagName) source code
 
hasAttribute(self, attrname) source code
 
insertBefore(self, newchild, refchild)
Insert a new child node before an existing child.
source code
 
removeAttribute(self, attrname) source code
 
removeChild(self, child)
Remove a child from this element.
source code
 
replaceChild(self, newchild, oldchild)
Replace an existing node with a new node.
source code
 
setAttribute(self, attrname, value) source code
 
start_tag(self, indent)
Generate the string for the element's start tag.
source code
 
unlink(self)
Break internal references within the document tree rooted on this element to promote garbage collection.
source code
 
write(self, fileobj=<epydoc.docintrospecter._DevNull instance at 0x7f39154699e0>, indent=u'')
Recursively write an element and it's children to a file.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
validattributes(cls) source code
Class Variables [hide private]
  tagName = None
hash(x)
  validchildren = frozenset([])
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, attrs=None)
(Constructor)

source code 

Construct an element. The argument is a sax.xmlreader.AttributesImpl object (see the xml.sax documentation, but it's basically a dictionary-like thing) used to set the element attributes.

Overrides: object.__init__

_verifyChildren(self, i)

source code 

Method used internally by some elements to verify that their children are from the allowed set and in the correct order following modifications to their child list. i is the index of the child that has just changed.

appendChild(self, child)

source code 

Add a child to this element. The child's parentNode attribute is updated, too.

insertBefore(self, newchild, refchild)

source code 

Insert a new child node before an existing child. It must be the case that refchild is a child of this node; if not, ValueError is raised. newchild is returned.

removeChild(self, child)

source code 

Remove a child from this element. The child element is returned, and it's parentNode element is reset. If the child will not be used any more, you should call its unlink() method to promote garbage collection.

replaceChild(self, newchild, oldchild)

source code 

Replace an existing node with a new node. It must be the case that oldchild is a child of this node; if not, ValueError is raised. newchild is returned.