ODFPY 1.2.0 |

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
odf.element.Element Class Reference

Creates a arbitrary element and is intended to be subclassed not used on its own. More...

Inheritance diagram for odf.element.Element:
[legend]
Collaboration diagram for odf.element.Element:
[legend]

## Public Member Functions
| __init__ (self, attributes=None, text=None, cdata=None, qname=None, qattributes=None, check_grammar=True, **args)
| get_knownns (self, prefix)
| Odfpy maintains a list of known namespaces.
| get_nsprefix (self, namespace)
| Odfpy maintains a list of known namespaces.
| allowed_attributes (self)
| addElement (self, element, check_grammar=True)
| adds an element to an Element
| addText (self, text, check_grammar=True)
| Adds text to an element Setting check_grammar=False turns off grammar checking.
| addCDATA (self, cdata, check_grammar=True)
| Adds CDATA to an element Setting check_grammar=False turns off grammar checking.
| removeAttribute (self, attr, check_grammar=True)
| Removes an attribute by name.
| setAttribute (self, attr, value, check_grammar=True)
| Add an attribute to the element This is sort of a convenience method.
| setAttrNS (self, namespace, localpart, value)
| Add an attribute to the element In case you need to add an attribute the library doesn't know about then you must provide the full qualified name It will not check that the attribute is legal according to the schema.
| getAttrNS (self, namespace, localpart)
| gets an attribute, given a namespace and a key
| removeAttrNS (self, namespace, localpart)
| getAttribute (self, attr)
| Get an attribute value.
| write_open_tag (self, level, f)
| write_close_tag (self, level, f)
| toXml (self, level, f)
| Generate an XML stream out of the tree structure.
| getElementsByType (self, element)
| Gets elements based on the type, which is function from text.py, draw.py etc.
| isInstanceOf (self, element)
| This is a check to see if the object is an instance of a type.
Public Member Functions inherited from odf.element.Node
| hasChildNodes (self)
| Tells whether this element has any children; text nodes, subelements whatever.
| insertBefore (self, newChild, refChild)
| Inserts the node newChild before the existing child node refChild.
| appendChild (self, newChild)
| Adds the node newChild to the end of the list of children of this node.
| removeChild (self, oldChild)
| Removes the child node indicated by oldChild from the list of children, and returns it.
| __str__ (self)
| __unicode__ (self)

## Public Attributes
| qname
| ownerDocument
| childNodes
| allowed_children
| tagName
| attributes
Public Attributes inherited from odf.element.Node
| tagName
| The DOM does not clearly specify what to return in this case.

## Static Public Attributes
| nodeType = Node.ELEMENT_NODE
dict | namespaces = {}
Static Public Attributes inherited from odf.element.Node
| parentNode = None
| nextSibling = None
| previousSibling = None
| doc

## Protected Member Functions
| _setOwnerDoc (self, element)
| _getElementsByObj (self, obj, accumulator)
Protected Member Functions inherited from odf.element.Node
| _get_childNodes (self)
| _get_firstChild (self)
| _get_lastChild (self)

## Static Protected Attributes
tuple | _child_node_types

## Detailed Description

Creates a arbitrary element and is intended to be subclassed not used on its own.

This element is the base of every element it defines a class which resembles a xml-element. The main advantage of this kind of implementation is that you don't have to create a toXML method for every different object. Every element consists of an attribute, optional subelements, optional text and optional cdata.

Definition at line 361 of file element.py.

## Constructor & Destructor Documentation

## ◆ __init__()

odf.element.Element.__init__ | ( |  | self,
|  |  | attributes = `None`,
|  |  | text = `None`,
|  |  | cdata = `None`,
|  |  | qname = `None`,
|  |  | qattributes = `None`,
|  |  | check_grammar = `True`,
|  | ** | args
| ) |  |

Definition at line 376 of file element.py.

## Member Function Documentation

## ◆ _getElementsByObj()

odf.element.Element._getElementsByObj | ( |  | self,
|  |  | obj,
|  |  | accumulator
| ) |  |
| protected

Definition at line 611 of file element.py.

Here is the caller graph for this function:

## ◆ _setOwnerDoc()

odf.element.Element._setOwnerDoc | ( |  | self,
|  |  | element
| ) |  |
| protected

Definition at line 440 of file element.py.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ addCDATA()

odf.element.Element.addCDATA | ( |  | self,
|  |  | cdata,
|  |  | check_grammar = `True`
| ) |  |

Adds CDATA to an element Setting check_grammar=False turns off grammar checking.

Definition at line 473 of file element.py.

Here is the call graph for this function:

## ◆ addElement()

odf.element.Element.addElement | ( |  | self,
|  |  | element,
|  |  | check_grammar = `True`
| ) |  |

adds an element to an Element

Element.addElement(Element)

Definition at line 451 of file element.py.

Here is the call graph for this function:

## ◆ addText()

odf.element.Element.addText | ( |  | self,
|  |  | text,
|  |  | check_grammar = `True`
| ) |  |

Adds text to an element Setting check_grammar=False turns off grammar checking.

Definition at line 463 of file element.py.

Here is the call graph for this function:

## ◆ allowed_attributes()

odf.element.Element.allowed_attributes | ( |  | self | ) |

Definition at line 437 of file element.py.

Here is the caller graph for this function:

## ◆ get_knownns()

odf.element.Element.get_knownns | ( |  | self,
|  |  | prefix
| ) |  |

Odfpy maintains a list of known namespaces.

In some cases a prefix is used, and we need to know which namespace it resolves to.

Definition at line 421 of file element.py.

## ◆ get_nsprefix()

odf.element.Element.get_nsprefix | ( |  | self,
|  |  | namespace
| ) |  |

Odfpy maintains a list of known namespaces.

In some cases we have a namespace URL, and needs to look up or assign the prefix for it.

Definition at line 430 of file element.py.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ getAttribute()

odf.element.Element.getAttribute | ( |  | self,
|  |  | attr
| ) |  |

Get an attribute value.

The method knows which namespace the attribute is in

Definition at line 563 of file element.py.

Here is the call graph for this function:

## ◆ getAttrNS()

odf.element.Element.getAttrNS | ( |  | self,
|  |  | namespace,
|  |  | localpart
| ) |  |

gets an attribute, given a namespace and a key

Parameters

  namespace | a unicode string or a bytes: the namespace
  localpart | a unicode string or a bytes: the key to get the attribute

Returns
  an attribute as a unicode string or a bytes: if both paramters are byte strings, it will be a bytes; if both attributes are unicode strings, it will be a unicode string

Definition at line 545 of file element.py.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ getElementsByType()

odf.element.Element.getElementsByType | ( |  | self,
|  |  | element
| ) |  |

Gets elements based on the type, which is function from text.py, draw.py etc.

Definition at line 620 of file element.py.

Here is the call graph for this function:

## ◆ isInstanceOf()

odf.element.Element.isInstanceOf | ( |  | self,
|  |  | element
| ) |  |

This is a check to see if the object is an instance of a type.

Definition at line 625 of file element.py.

## ◆ removeAttribute()

odf.element.Element.removeAttribute | ( |  | self,
|  |  | attr,
|  |  | check_grammar = `True`
| ) |  |

Removes an attribute by name.

Definition at line 480 of file element.py.

Here is the call graph for this function:

## ◆ removeAttrNS()

odf.element.Element.removeAttrNS | ( |  | self,
|  |  | namespace,
|  |  | localpart
| ) |  |

Definition at line 558 of file element.py.

Here is the caller graph for this function:

## ◆ setAttribute()

odf.element.Element.setAttribute | ( |  | self,
|  |  | attr,
|  |  | value,
|  |  | check_grammar = `True`
| ) |  |

Add an attribute to the element This is sort of a convenience method.

All attributes in ODF have namespaces. The library knows what attributes are legal and then allows the user to provide the attribute as a keyword argument and the library will add the correct namespace. Must overwrite, If attribute already exists.

Definition at line 503 of file element.py.

Here is the call graph for this function:

## ◆ setAttrNS()

odf.element.Element.setAttrNS | ( |  | self,
|  |  | namespace,
|  |  | localpart,
|  |  | value
| ) |  |

Add an attribute to the element In case you need to add an attribute the library doesn't know about then you must provide the full qualified name It will not check that the attribute is legal according to the schema.

Must overwrite, If attribute already exists.

Definition at line 528 of file element.py.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ toXml()

odf.element.Element.toXml | ( |  | self,
|  |  | level,
|  |  | f
| ) |  |

Generate an XML stream out of the tree structure.

Parameters

  level | integer: level in the XML tree; zero at root of the tree
  f | an open writable file able to accept unicode strings

Definition at line 595 of file element.py.

Here is the call graph for this function:

## ◆ write_close_tag()

odf.element.Element.write_close_tag | ( |  | self,
|  |  | level,
|  |  | f
| ) |  |

Definition at line 587 of file element.py.

## ◆ write_open_tag()

odf.element.Element.write_open_tag | ( |  | self,
|  |  | level,
|  |  | f
| ) |  |

Definition at line 577 of file element.py.

Here is the call graph for this function:

## Member Data Documentation

## ◆ _child_node_types

odf.element.Element._child_node_types
| static protected

Definition at line 369 of file element.py.

## ◆ allowed_children

odf.element.Element.allowed_children

Definition at line 382 of file element.py.

## ◆ attributes

odf.element.Element.attributes

Definition at line 393 of file element.py.

## ◆ childNodes

odf.element.Element.childNodes

Definition at line 381 of file element.py.

## ◆ namespaces

dict odf.element.Element.namespaces = {}
| static

Definition at line 364 of file element.py.

## ◆ nodeType

odf.element.Element.nodeType = Node.ELEMENT_NODE
| static

Definition at line 363 of file element.py.

## ◆ ownerDocument

odf.element.Element.ownerDocument

Definition at line 380 of file element.py.

## ◆ qname

odf.element.Element.qname

Definition at line 378 of file element.py.

## ◆ tagName

odf.element.Element.tagName

Definition at line 384 of file element.py.

The documentation for this class was generated from the following file:

- odf/element.py