Creates a arbitrary element and is intended to be subclassed not used on its own. More...
Public Member Functions | |
def | __init__ (self, attributes=None, text=None, cdata=None, qname=None, qattributes=None, check_grammar=True, **args) |
def | get_knownns (self, prefix) |
Odfpy maintains a list of known namespaces. More... | |
def | get_nsprefix (self, namespace) |
Odfpy maintains a list of known namespaces. More... | |
def | allowed_attributes (self) |
def | addElement (self, element, check_grammar=True) |
adds an element to an Element More... | |
def | addText (self, text, check_grammar=True) |
Adds text to an element Setting check_grammar=False turns off grammar checking. More... | |
def | addCDATA (self, cdata, check_grammar=True) |
Adds CDATA to an element Setting check_grammar=False turns off grammar checking. More... | |
def | removeAttribute (self, attr, check_grammar=True) |
Removes an attribute by name. More... | |
def | setAttribute (self, attr, value, check_grammar=True) |
Add an attribute to the element This is sort of a convenience method. More... | |
def | 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. More... | |
def | getAttrNS (self, namespace, localpart) |
def | removeAttrNS (self, namespace, localpart) |
def | getAttribute (self, attr) |
Get an attribute value. More... | |
def | write_open_tag (self, level, f) |
def | write_close_tag (self, level, f) |
def | toXml (self, level, f) |
def | getElementsByType (self, element) |
Gets elements based on the type, which is function from text.py, draw.py etc. More... | |
def | isInstanceOf (self, element) |
This is a check to see if the object is an instance of a type. More... | |
![]() | |
def | hasChildNodes (self) |
Tells whether this element has any children; text nodes, subelements, whatever. More... | |
def | insertBefore (self, newChild, refChild) |
Inserts the node newChild before the existing child node refChild. More... | |
def | appendChild (self, newChild) |
Adds the node newChild to the end of the list of children of this node. More... | |
def | removeChild (self, oldChild) |
Removes the child node indicated by oldChild from the list of children, and returns it. More... | |
def | __str__ (self) |
def | __unicode__ (self) |
Public Attributes | |
qname | |
ownerDocument | |
childNodes | |
allowed_children | |
tagName | |
attributes | |
Static Public Attributes | |
nodeType = Node.ELEMENT_NODE | |
dictionary | namespaces = {} |
![]() | |
parentNode = None | |
nextSibling = None | |
previousSibling = None | |
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 357 of file element.py.
def odf.element.Element.__init__ | ( | self, | |
attributes = None , |
|||
text = None , |
|||
cdata = None , |
|||
qname = None , |
|||
qattributes = None , |
|||
check_grammar = True , |
|||
** | args | ||
) |
Definition at line 369 of file element.py.
def 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 469 of file element.py.
def odf.element.Element.addElement | ( | self, | |
element, | |||
check_grammar = True |
|||
) |
adds an element to an Element
Element.addElement(Element)
Definition at line 445 of file element.py.
def 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 458 of file element.py.
def odf.element.Element.allowed_attributes | ( | self | ) |
Definition at line 432 of file element.py.
def 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 415 of file element.py.
def 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 425 of file element.py.
def odf.element.Element.getAttribute | ( | self, | |
attr | |||
) |
Get an attribute value.
The method knows which namespace the attribute is in
Definition at line 564 of file element.py.
def odf.element.Element.getAttrNS | ( | self, | |
namespace, | |||
localpart | |||
) |
gets an attribute, given a namespace and a key @param namespace a unicode string or a bytes: the namespace @param localpart a unicode string or a bytes: the key to get the attribute @return 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.
def odf.element.Element.getElementsByType | ( | self, | |
element | |||
) |
Gets elements based on the type, which is function from text.py, draw.py etc.
Definition at line 623 of file element.py.
def odf.element.Element.isInstanceOf | ( | self, | |
element | |||
) |
This is a check to see if the object is an instance of a type.
Definition at line 629 of file element.py.
def odf.element.Element.removeAttribute | ( | self, | |
attr, | |||
check_grammar = True |
|||
) |
Removes an attribute by name.
Definition at line 477 of file element.py.
def odf.element.Element.removeAttrNS | ( | self, | |
namespace, | |||
localpart | |||
) |
def 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 501 of file element.py.
def 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 527 of file element.py.
def odf.element.Element.toXml | ( | self, | |
level, | |||
f | |||
) |
Generate an XML stream out of the tree structure @param level integer: level in the XML tree; zero at root of the tree @param f an open writable file able to accept unicode strings
Definition at line 597 of file element.py.
def odf.element.Element.write_close_tag | ( | self, | |
level, | |||
f | |||
) |
Definition at line 588 of file element.py.
def odf.element.Element.write_open_tag | ( | self, | |
level, | |||
f | |||
) |
odf.element.Element.allowed_children |
Definition at line 375 of file element.py.
odf.element.Element.attributes |
Definition at line 386 of file element.py.
odf.element.Element.childNodes |
Definition at line 374 of file element.py.
|
static |
Definition at line 360 of file element.py.
|
static |
Definition at line 359 of file element.py.
odf.element.Element.ownerDocument |
Definition at line 373 of file element.py.
odf.element.Element.qname |
Definition at line 371 of file element.py.
odf.element.Element.tagName |
Definition at line 377 of file element.py.