MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / Element

Class Element

suds/sax/element.py:30–950  ·  view source on GitHub ↗

An XML element object. @ivar parent: The node containing this attribute @type parent: L{Element} @ivar prefix: The I{optional} namespace prefix. @type prefix: basestring @ivar name: The I{unqualified} name of the attribute @type name: basestring @ivar expns: An expli

Source from the content-addressed store, hash-verified

28
29
30class Element:
31 """
32 An XML element object.
33 @ivar parent: The node containing this attribute
34 @type parent: L{Element}
35 @ivar prefix: The I{optional} namespace prefix.
36 @type prefix: basestring
37 @ivar name: The I{unqualified} name of the attribute
38 @type name: basestring
39 @ivar expns: An explicit namespace (xmlns="...").
40 @type expns: (I{prefix}, I{name})
41 @ivar nsprefixes: A mapping of prefixes to namespaces.
42 @type nsprefixes: dict
43 @ivar attributes: A list of XML attributes.
44 @type attributes: [I{Attribute},]
45 @ivar text: The element's I{text} content.
46 @type text: basestring
47 @ivar children: A list of child elements.
48 @type children: [I{Element},]
49 @cvar matcher: A collection of I{lambda} for string matching.
50 @cvar specialprefixes: A dictionary of builtin-special prefixes.
51 """
52
53 matcher = {
54 'eq': lambda a, b: a == b,
55 'startswith': lambda a, b: a.startswith(b),
56 'endswith': lambda a, b: a.endswith(b),
57 'contains': lambda a, b: b in a
58 }
59
60 specialprefixes = {
61 Namespace.xmlns[0]: Namespace.xmlns[1]
62 }
63
64 @classmethod
65 def buildPath(self, parent, path):
66 """
67 Build the specifed pat as a/b/c where missing intermediate nodes are
68 built automatically.
69 @param parent: A parent element on which the path is built.
70 @type parent: I{Element}
71 @param path: A simple path separated by (/).
72 @type path: basestring
73 @return: The leaf node of I{path}.
74 @rtype: L{Element}
75 """
76 for tag in path.split('/'):
77 child = parent.getChild(tag)
78 if child is None:
79 child = Element(tag, parent)
80 parent = child
81 return child
82
83 def __init__(self, name, parent=None, ns=None):
84 """
85 @param name: The element's (tag) name. May cotain a prefix.
86 @type name: basestring
87 @param parent: An optional parent element.

Callers 15

createMethod · 0.90
resolveMethod · 0.90
add_operationsMethod · 0.90
xmlMethod · 0.90
xmlMethod · 0.90
xmlMethod · 0.90
nodeMethod · 0.90
nodeMethod · 0.90
startElementMethod · 0.90
methodMethod · 0.90
envelopeMethod · 0.90
headerMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected