Creates a arbitrary element and is intended to be subclassed not used on its own. More...
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. | |
![]() | |
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 = qname | |
ownerDocument = None | |
list | childNodes = [] |
allowed_children = grammar.allowed_children.get(self.qname) | |
str | tagName = prefix + ":" + self.qname[1] |
dict | attributes = {} |
![]() | |
childNodes | |
tagName | |
The DOM does not clearly specify what to return in this case. | |
ownerDocument | |
Static Public Attributes | |
nodeType = Node.ELEMENT_NODE | |
dict | namespaces = {} |
![]() | |
parentNode = None | |
nextSibling = None | |
previousSibling = None | |
doc | |
Protected Member Functions | |
_setOwnerDoc (self, element) | |
_getElementsByObj (self, obj, accumulator) | |
![]() | |
_get_childNodes (self) | |
_get_firstChild (self) | |
_get_lastChild (self) | |
Static Protected Attributes | |
tuple | _child_node_types |
Additional Inherited Members | |
![]() | |
_child_node_types | |
The DOM does not clearly specify what to return in this case. | |
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.
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.
|
protected |
|
protected |
Definition at line 440 of file element.py.
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.
odf.element.Element.addElement | ( | self, | |
element, | |||
check_grammar = True ) |
adds an element to an Element
Definition at line 451 of file element.py.
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.
odf.element.Element.allowed_attributes | ( | self | ) |
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.
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.
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.
odf.element.Element.getAttrNS | ( | self, | |
namespace, | |||
localpart ) |
gets an attribute, given a namespace and a key
namespace | a unicode string or a bytes: the namespace |
localpart | a unicode string or a bytes: the key to get the attribute |
Definition at line 545 of file element.py.
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.
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.
odf.element.Element.removeAttribute | ( | self, | |
attr, | |||
check_grammar = True ) |
Removes an attribute by name.
Definition at line 480 of file element.py.
odf.element.Element.removeAttrNS | ( | self, | |
namespace, | |||
localpart ) |
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.
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.
odf.element.Element.toXml | ( | self, | |
level, | |||
f ) |
Generate an XML stream out of the tree structure.
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.
odf.element.Element.write_close_tag | ( | self, | |
level, | |||
f ) |
Definition at line 587 of file element.py.
odf.element.Element.write_open_tag | ( | self, | |
level, | |||
f ) |
|
staticprotected |
Definition at line 369 of file element.py.
odf.element.Element.allowed_children = grammar.allowed_children.get(self.qname) |
Definition at line 382 of file element.py.
dict odf.element.Element.attributes = {} |
Definition at line 393 of file element.py.
odf.element.Element.childNodes = [] |
Definition at line 381 of file element.py.
|
static |
Definition at line 364 of file element.py.
|
static |
Definition at line 363 of file element.py.
odf.element.Element.ownerDocument = None |
Definition at line 380 of file element.py.
odf.element.Element.qname = qname |
Definition at line 378 of file element.py.
odf.element.Element.tagName = prefix + ":" + self.qname[1] |
Definition at line 384 of file element.py.