Imported Upstream version 2.3.5
[platform/upstream/python-lxml.git] / doc / html / api / lxml.builder-pysrc.html
1 <?xml version="1.0" encoding="ascii"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3           "DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6   <title>lxml.builder</title>
7   <link rel="stylesheet" href="epydoc.css" type="text/css" />
8   <script type="text/javascript" src="epydoc.js"></script>
9 </head>
10
11 <body bgcolor="white" text="black" link="blue" vlink="#204080"
12       alink="#204080">
13 <!-- ==================== NAVIGATION BAR ==================== -->
14 <table class="navbar" border="0" width="100%" cellpadding="0"
15        bgcolor="#a0c0ff" cellspacing="0">
16   <tr valign="middle">
17   <!-- Home link -->
18       <th>&nbsp;&nbsp;&nbsp;<a
19         href="lxml-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
20
21   <!-- Tree link -->
22       <th>&nbsp;&nbsp;&nbsp;<a
23         href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
24
25   <!-- Index link -->
26       <th>&nbsp;&nbsp;&nbsp;<a
27         href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
28
29   <!-- Help link -->
30       <th>&nbsp;&nbsp;&nbsp;<a
31         href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
32
33   <!-- Project homepage -->
34       <th class="navbar" align="right" width="100%">
35         <table border="0" cellpadding="0" cellspacing="0">
36           <tr><th class="navbar" align="center"
37             ><a class="navbar" target="_top" href="/">lxml API</a></th>
38           </tr></table></th>
39   </tr>
40 </table>
41 <table width="100%" cellpadding="0" cellspacing="0">
42   <tr valign="top">
43     <td width="100%">
44       <span class="breadcrumbs">
45         <a href="lxml-module.html">Package&nbsp;lxml</a> ::
46         Module&nbsp;builder
47       </span>
48     </td>
49     <td>
50       <table cellpadding="0" cellspacing="0">
51         <!-- hide/show private -->
52         <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
53     onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
54         <tr><td align="right"><span class="options"
55             >[<a href="frames.html" target="_top">frames</a
56             >]&nbsp;|&nbsp;<a href="lxml.builder-pysrc.html"
57             target="_top">no&nbsp;frames</a>]</span></td></tr>
58       </table>
59     </td>
60   </tr>
61 </table>
62 <h1 class="epydoc">Source Code for <a href="lxml.builder-module.html">Module lxml.builder</a></h1>
63 <pre class="py-src">
64 <a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-comment">#</tt> </tt>
65 <a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-comment"># Element generator factory by Fredrik Lundh.</tt> </tt>
66 <a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-comment">#</tt> </tt>
67 <a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-comment"># Source:</tt> </tt>
68 <a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-comment">#    http://online.effbot.org/2006_11_01_archive.htm#et-builder</tt> </tt>
69 <a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-comment">#    http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py</tt> </tt>
70 <a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-comment">#</tt> </tt>
71 <a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-comment"># --------------------------------------------------------------------</tt> </tt>
72 <a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-comment"># The ElementTree toolkit is</tt> </tt>
73 <a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"><tt class="py-comment">#</tt> </tt>
74 <a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt class="py-comment"># Copyright (c) 1999-2004 by Fredrik Lundh</tt> </tt>
75 <a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line"><tt class="py-comment">#</tt> </tt>
76 <a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line"><tt class="py-comment"># By obtaining, using, and/or copying this software and/or its</tt> </tt>
77 <a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-comment"># associated documentation, you agree that you have read, understood,</tt> </tt>
78 <a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-comment"># and will comply with the following terms and conditions:</tt> </tt>
79 <a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-comment">#</tt> </tt>
80 <a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-comment"># Permission to use, copy, modify, and distribute this software and</tt> </tt>
81 <a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line"><tt class="py-comment"># its associated documentation for any purpose and without fee is</tt> </tt>
82 <a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line"><tt class="py-comment"># hereby granted, provided that the above copyright notice appears in</tt> </tt>
83 <a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"><tt class="py-comment"># all copies, and that both that copyright notice and this permission</tt> </tt>
84 <a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt class="py-comment"># notice appear in supporting documentation, and that the name of</tt> </tt>
85 <a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"><tt class="py-comment"># Secret Labs AB or the author not be used in advertising or publicity</tt> </tt>
86 <a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt class="py-comment"># pertaining to distribution of the software without specific, written</tt> </tt>
87 <a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"><tt class="py-comment"># prior permission.</tt> </tt>
88 <a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"><tt class="py-comment">#</tt> </tt>
89 <a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line"><tt class="py-comment"># SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD</tt> </tt>
90 <a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt class="py-comment"># TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-</tt> </tt>
91 <a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line"><tt class="py-comment"># ABILITY AND FITNESS.  IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR</tt> </tt>
92 <a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line"><tt class="py-comment"># BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY</tt> </tt>
93 <a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line"><tt class="py-comment"># DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,</tt> </tt>
94 <a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line"><tt class="py-comment"># WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS</tt> </tt>
95 <a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line"><tt class="py-comment"># ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE</tt> </tt>
96 <a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line"><tt class="py-comment"># OF THIS SOFTWARE.</tt> </tt>
97 <a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line"><tt class="py-comment"># --------------------------------------------------------------------</tt> </tt>
98 <a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line"> </tt>
99 <a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
100 <a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line"><tt class="py-docstring">The ``E`` Element factory for generating XML documents.</tt> </tt>
101 <a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
102 <a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line"> </tt>
103 <a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-0" class="py-name" targets="Package lxml=lxml-module.html"><a title="lxml" class="py-name" href="#" onclick="return doclink('link-0', 'lxml', 'link-0');">lxml</a></tt><tt class="py-op">.</tt><tt id="link-1" class="py-name" targets="Module lxml.etree=lxml.etree-module.html,Variable lxml.sax.ElementTreeContentHandler.etree=lxml.sax.ElementTreeContentHandler-class.html#etree,Variable lxml.tests.test_elementtree.CElementTreeTestCase.etree=lxml.tests.test_elementtree.CElementTreeTestCase-class.html#etree,Variable lxml.tests.test_elementtree.ETreeTestCaseBase.etree=lxml.tests.test_elementtree.ETreeTestCaseBase-class.html#etree,Variable lxml.tests.test_io.IOTestCaseBase.etree=lxml.tests.test_io.IOTestCaseBase-class.html#etree"><a title="lxml.etree
104 lxml.sax.ElementTreeContentHandler.etree
105 lxml.tests.test_elementtree.CElementTreeTestCase.etree
106 lxml.tests.test_elementtree.ETreeTestCaseBase.etree
107 lxml.tests.test_io.IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-1', 'etree', 'link-1');">etree</a></tt> <tt class="py-keyword">as</tt> <tt class="py-name">ET</tt> </tt>
108 <a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line"> </tt>
109 <a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
110 <a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line">    <tt class="py-keyword">from</tt> <tt class="py-name">functools</tt> <tt class="py-keyword">import</tt> <tt class="py-name">partial</tt> </tt>
111 <a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line"><tt class="py-keyword">except</tt> <tt class="py-name">ImportError</tt><tt class="py-op">:</tt> </tt>
112 <a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line">    <tt class="py-comment"># fake it for pre-2.5 releases</tt> </tt>
113 <a name="partial"></a><div id="partial-def"><a name="L46"></a><tt class="py-lineno"> 46</tt> <a class="py-toggle" href="#" id="partial-toggle" onclick="return toggle('partial');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.builder-module.html#partial">partial</a><tt class="py-op">(</tt><tt class="py-param">func</tt><tt class="py-op">,</tt> <tt class="py-param">tag</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
114 </div><div id="partial-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="partial-expanded"><a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-keyword">lambda</tt> <tt class="py-op">*</tt><tt class="py-name">args</tt><tt class="py-op">,</tt> <tt class="py-op">**</tt><tt class="py-name">kwargs</tt><tt class="py-op">:</tt> <tt class="py-name">func</tt><tt class="py-op">(</tt><tt id="link-2" class="py-name" targets="Variable lxml.etree._Comment.tag=lxml.etree._Comment-class.html#tag,Variable lxml.etree._Element.tag=lxml.etree._Element-class.html#tag,Variable lxml.etree._Entity.tag=lxml.etree._Entity-class.html#tag,Variable lxml.etree._ProcessingInstruction.tag=lxml.etree._ProcessingInstruction-class.html#tag,Variable lxml.etree._ReadOnlyProxy.tag=lxml.etree._ReadOnlyProxy-class.html#tag,Function lxml.tests.test_xpathevaluator.tag()=lxml.tests.test_xpathevaluator-module.html#tag,Variable xml.etree.ElementTree.Element.tag=xml.etree.ElementTree.Element-class.html#tag"><a title="lxml.etree._Comment.tag
115 lxml.etree._Element.tag
116 lxml.etree._Entity.tag
117 lxml.etree._ProcessingInstruction.tag
118 lxml.etree._ReadOnlyProxy.tag
119 lxml.tests.test_xpathevaluator.tag
120 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-2', 'tag', 'link-2');">tag</a></tt><tt class="py-op">,</tt> <tt class="py-op">*</tt><tt class="py-name">args</tt><tt class="py-op">,</tt> <tt class="py-op">**</tt><tt class="py-name">kwargs</tt><tt class="py-op">)</tt> </tt>
121 </div><a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line"> </tt>
122 <a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
123 <a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line">    <tt id="link-3" class="py-name" targets="Function lxml.builder.callable()=lxml.builder-module.html#callable"><a title="lxml.builder.callable" class="py-name" href="#" onclick="return doclink('link-3', 'callable', 'link-3');">callable</a></tt> </tt>
124 <a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line"><tt class="py-keyword">except</tt> <tt class="py-name">NameError</tt><tt class="py-op">:</tt> </tt>
125 <a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line">    <tt class="py-comment"># Python 3</tt> </tt>
126 <a name="callable"></a><div id="callable-def"><a name="L53"></a><tt class="py-lineno"> 53</tt> <a class="py-toggle" href="#" id="callable-toggle" onclick="return toggle('callable');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.builder-module.html#callable">callable</a><tt class="py-op">(</tt><tt class="py-param">f</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
127 </div><div id="callable-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="callable-expanded"><a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt id="link-4" class="py-name" targets="Method lxml.objectify.ObjectPath.hasattr()=lxml.objectify.ObjectPath-class.html#hasattr"><a title="lxml.objectify.ObjectPath.hasattr" class="py-name" href="#" onclick="return doclink('link-4', 'hasattr', 'link-4');">hasattr</a></tt><tt class="py-op">(</tt><tt class="py-name">f</tt><tt class="py-op">,</tt> <tt class="py-string">'__call__'</tt><tt class="py-op">)</tt> </tt>
128 </div><a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line"> </tt>
129 <a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
130 <a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line">    <tt class="py-name">basestring</tt> <tt class="py-op">=</tt> <tt class="py-name">__builtins__</tt><tt class="py-op">[</tt><tt class="py-string">"basestring"</tt><tt class="py-op">]</tt> </tt>
131 <a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line"><tt class="py-keyword">except</tt> <tt class="py-op">(</tt><tt class="py-name">NameError</tt><tt class="py-op">,</tt> <tt class="py-name">KeyError</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
132 <a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line">    <tt class="py-name">basestring</tt> <tt class="py-op">=</tt> <tt class="py-name">str</tt> </tt>
133 <a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line"> </tt>
134 <a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
135 <a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line">    <tt class="py-name">unicode</tt> <tt class="py-op">=</tt> <tt class="py-name">__builtins__</tt><tt class="py-op">[</tt><tt class="py-string">"unicode"</tt><tt class="py-op">]</tt> </tt>
136 <a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line"><tt class="py-keyword">except</tt> <tt class="py-op">(</tt><tt class="py-name">NameError</tt><tt class="py-op">,</tt> <tt class="py-name">KeyError</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
137 <a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line">    <tt class="py-name">unicode</tt> <tt class="py-op">=</tt> <tt class="py-name">str</tt> </tt>
138 <a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line"> </tt>
139 <a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line"> </tt>
140 <a name="ElementMaker"></a><div id="ElementMaker-def"><a name="L67"></a><tt class="py-lineno"> 67</tt> <a class="py-toggle" href="#" id="ElementMaker-toggle" onclick="return toggle('ElementMaker');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="lxml.builder.ElementMaker-class.html">ElementMaker</a><tt class="py-op">(</tt><tt class="py-base-class">object</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
141 </div><div id="ElementMaker-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="ElementMaker-expanded"><a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line">    <tt class="py-docstring">"""Element generator factory.</tt> </tt>
142 <a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
143 <a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line"><tt class="py-docstring">    Unlike the ordinary Element factory, the E factory allows you to pass in</tt> </tt>
144 <a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line"><tt class="py-docstring">    more than just a tag and some optional attributes; you can also pass in</tt> </tt>
145 <a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line"><tt class="py-docstring">    text and other elements.  The text is added as either text or tail</tt> </tt>
146 <a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line"><tt class="py-docstring">    attributes, and elements are inserted at the right spot.  Some small</tt> </tt>
147 <a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line"><tt class="py-docstring">    examples::</tt> </tt>
148 <a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
149 <a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; from lxml import etree as ET</tt> </tt>
150 <a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; from lxml.builder import E</tt> </tt>
151 <a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
152 <a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; ET.tostring(E("tag"))</tt> </tt>
153 <a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line"><tt class="py-docstring">        '&lt;tag/&gt;'</tt> </tt>
154 <a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; ET.tostring(E("tag", "text"))</tt> </tt>
155 <a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line"><tt class="py-docstring">        '&lt;tag&gt;text&lt;/tag&gt;'</tt> </tt>
156 <a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; ET.tostring(E("tag", "text", key="value"))</tt> </tt>
157 <a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line"><tt class="py-docstring">        '&lt;tag key="value"&gt;text&lt;/tag&gt;'</tt> </tt>
158 <a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; ET.tostring(E("tag", E("subtag", "text"), "tail"))</tt> </tt>
159 <a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line"><tt class="py-docstring">        '&lt;tag&gt;&lt;subtag&gt;text&lt;/subtag&gt;tail&lt;/tag&gt;'</tt> </tt>
160 <a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
161 <a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line"><tt class="py-docstring">    For simple tags, the factory also allows you to write ``E.tag(...)`` instead</tt> </tt>
162 <a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line"><tt class="py-docstring">    of ``E('tag', ...)``::</tt> </tt>
163 <a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
164 <a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; ET.tostring(E.tag())</tt> </tt>
165 <a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line"><tt class="py-docstring">        '&lt;tag/&gt;'</tt> </tt>
166 <a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; ET.tostring(E.tag("text"))</tt> </tt>
167 <a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line"><tt class="py-docstring">        '&lt;tag&gt;text&lt;/tag&gt;'</tt> </tt>
168 <a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; ET.tostring(E.tag(E.subtag("text"), "tail"))</tt> </tt>
169 <a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line"><tt class="py-docstring">        '&lt;tag&gt;&lt;subtag&gt;text&lt;/subtag&gt;tail&lt;/tag&gt;'</tt> </tt>
170 <a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
171 <a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line"><tt class="py-docstring">    Here's a somewhat larger example; this shows how to generate HTML</tt> </tt>
172 <a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line"><tt class="py-docstring">    documents, using a mix of prepared factory functions for inline elements,</tt> </tt>
173 <a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line"><tt class="py-docstring">    nested ``E.tag`` calls, and embedded XHTML fragments::</tt> </tt>
174 <a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
175 <a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line"><tt class="py-docstring">        # some common inline elements</tt> </tt>
176 <a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line"><tt class="py-docstring">        A = E.a</tt> </tt>
177 <a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line"><tt class="py-docstring">        I = E.i</tt> </tt>
178 <a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line"><tt class="py-docstring">        B = E.b</tt> </tt>
179 <a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
180 <a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line"><tt class="py-docstring">        def CLASS(v):</tt> </tt>
181 <a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line"><tt class="py-docstring">            # helper function, 'class' is a reserved word</tt> </tt>
182 <a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line"><tt class="py-docstring">            return {'class': v}</tt> </tt>
183 <a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
184 <a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line"><tt class="py-docstring">        page = (</tt> </tt>
185 <a name="L112"></a><tt class="py-lineno">112</tt>  <tt class="py-line"><tt class="py-docstring">            E.html(</tt> </tt>
186 <a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line"><tt class="py-docstring">                E.head(</tt> </tt>
187 <a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line"><tt class="py-docstring">                    E.title("This is a sample document")</tt> </tt>
188 <a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line"><tt class="py-docstring">                ),</tt> </tt>
189 <a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line"><tt class="py-docstring">                E.body(</tt> </tt>
190 <a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line"><tt class="py-docstring">                    E.h1("Hello!", CLASS("title")),</tt> </tt>
191 <a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line"><tt class="py-docstring">                    E.p("This is a paragraph with ", B("bold"), " text in it!"),</tt> </tt>
192 <a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line"><tt class="py-docstring">                    E.p("This is another paragraph, with a ",</tt> </tt>
193 <a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line"><tt class="py-docstring">                        A("link", href="http://www.python.org"), "."),</tt> </tt>
194 <a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line"><tt class="py-docstring">                    E.p("Here are some reservered characters: &lt;spam&amp;egg&gt;."),</tt> </tt>
195 <a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line"><tt class="py-docstring">                    ET.XML("&lt;p&gt;And finally, here is an embedded XHTML fragment.&lt;/p&gt;"),</tt> </tt>
196 <a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line"><tt class="py-docstring">                )</tt> </tt>
197 <a name="L124"></a><tt class="py-lineno">124</tt>  <tt class="py-line"><tt class="py-docstring">            )</tt> </tt>
198 <a name="L125"></a><tt class="py-lineno">125</tt>  <tt class="py-line"><tt class="py-docstring">        )</tt> </tt>
199 <a name="L126"></a><tt class="py-lineno">126</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
200 <a name="L127"></a><tt class="py-lineno">127</tt>  <tt class="py-line"><tt class="py-docstring">        print ET.tostring(page)</tt> </tt>
201 <a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
202 <a name="L129"></a><tt class="py-lineno">129</tt>  <tt class="py-line"><tt class="py-docstring">    Here's a prettyprinted version of the output from the above script::</tt> </tt>
203 <a name="L130"></a><tt class="py-lineno">130</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
204 <a name="L131"></a><tt class="py-lineno">131</tt>  <tt class="py-line"><tt class="py-docstring">        &lt;html&gt;</tt> </tt>
205 <a name="L132"></a><tt class="py-lineno">132</tt>  <tt class="py-line"><tt class="py-docstring">          &lt;head&gt;</tt> </tt>
206 <a name="L133"></a><tt class="py-lineno">133</tt>  <tt class="py-line"><tt class="py-docstring">            &lt;title&gt;This is a sample document&lt;/title&gt;</tt> </tt>
207 <a name="L134"></a><tt class="py-lineno">134</tt>  <tt class="py-line"><tt class="py-docstring">          &lt;/head&gt;</tt> </tt>
208 <a name="L135"></a><tt class="py-lineno">135</tt>  <tt class="py-line"><tt class="py-docstring">          &lt;body&gt;</tt> </tt>
209 <a name="L136"></a><tt class="py-lineno">136</tt>  <tt class="py-line"><tt class="py-docstring">            &lt;h1 class="title"&gt;Hello!&lt;/h1&gt;</tt> </tt>
210 <a name="L137"></a><tt class="py-lineno">137</tt>  <tt class="py-line"><tt class="py-docstring">            &lt;p&gt;This is a paragraph with &lt;b&gt;bold&lt;/b&gt; text in it!&lt;/p&gt;</tt> </tt>
211 <a name="L138"></a><tt class="py-lineno">138</tt>  <tt class="py-line"><tt class="py-docstring">            &lt;p&gt;This is another paragraph, with &lt;a href="http://www.python.org"&gt;link&lt;/a&gt;.&lt;/p&gt;</tt> </tt>
212 <a name="L139"></a><tt class="py-lineno">139</tt>  <tt class="py-line"><tt class="py-docstring">            &lt;p&gt;Here are some reservered characters: &amp;lt;spam&amp;amp;egg&amp;gt;.&lt;/p&gt;</tt> </tt>
213 <a name="L140"></a><tt class="py-lineno">140</tt>  <tt class="py-line"><tt class="py-docstring">            &lt;p&gt;And finally, here is an embedded XHTML fragment.&lt;/p&gt;</tt> </tt>
214 <a name="L141"></a><tt class="py-lineno">141</tt>  <tt class="py-line"><tt class="py-docstring">          &lt;/body&gt;</tt> </tt>
215 <a name="L142"></a><tt class="py-lineno">142</tt>  <tt class="py-line"><tt class="py-docstring">        &lt;/html&gt;</tt> </tt>
216 <a name="L143"></a><tt class="py-lineno">143</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
217 <a name="L144"></a><tt class="py-lineno">144</tt>  <tt class="py-line"><tt class="py-docstring">    For namespace support, you can pass a namespace map (``nsmap``)</tt> </tt>
218 <a name="L145"></a><tt class="py-lineno">145</tt>  <tt class="py-line"><tt class="py-docstring">    and/or a specific target ``namespace`` to the ElementMaker class::</tt> </tt>
219 <a name="L146"></a><tt class="py-lineno">146</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
220 <a name="L147"></a><tt class="py-lineno">147</tt>  <tt class="py-line"><tt class="py-docstring">    &gt;&gt;&gt; E = ElementMaker(namespace="http://my.ns/")</tt> </tt>
221 <a name="L148"></a><tt class="py-lineno">148</tt>  <tt class="py-line"><tt class="py-docstring">    &gt;&gt;&gt; print(ET.tostring( E.test ))</tt> </tt>
222 <a name="L149"></a><tt class="py-lineno">149</tt>  <tt class="py-line"><tt class="py-docstring">    &lt;test xmlns="http://my.ns/"/&gt;</tt> </tt>
223 <a name="L150"></a><tt class="py-lineno">150</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
224 <a name="L151"></a><tt class="py-lineno">151</tt>  <tt class="py-line"><tt class="py-docstring">    &gt;&gt;&gt; E = ElementMaker(namespace="http://my.ns/", nsmap={'p':'http://my.ns/'})</tt> </tt>
225 <a name="L152"></a><tt class="py-lineno">152</tt>  <tt class="py-line"><tt class="py-docstring">    &gt;&gt;&gt; print(ET.tostring( E.test ))</tt> </tt>
226 <a name="L153"></a><tt class="py-lineno">153</tt>  <tt class="py-line"><tt class="py-docstring">    &lt;p:test xmlns:p="http://my.ns/"/&gt;</tt> </tt>
227 <a name="L154"></a><tt class="py-lineno">154</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
228 <a name="L155"></a><tt class="py-lineno">155</tt>  <tt class="py-line"> </tt>
229 <a name="ElementMaker.__init__"></a><div id="ElementMaker.__init__-def"><a name="L156"></a><tt class="py-lineno">156</tt> <a class="py-toggle" href="#" id="ElementMaker.__init__-toggle" onclick="return toggle('ElementMaker.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.builder.ElementMaker-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">typemap</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> </tt>
230 <a name="L157"></a><tt class="py-lineno">157</tt>  <tt class="py-line">                 <tt class="py-param">namespace</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> <tt class="py-param">nsmap</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> <tt class="py-param">makeelement</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
231 </div><div id="ElementMaker.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ElementMaker.__init__-expanded"><a name="L158"></a><tt class="py-lineno">158</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-5" class="py-name" targets="Variable lxml.etree.QName.namespace=lxml.etree.QName-class.html#namespace"><a title="lxml.etree.QName.namespace" class="py-name" href="#" onclick="return doclink('link-5', 'namespace', 'link-5');">namespace</a></tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
232 <a name="L159"></a><tt class="py-lineno">159</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_namespace</tt> <tt class="py-op">=</tt> <tt class="py-string">'{'</tt> <tt class="py-op">+</tt> <tt id="link-6" class="py-name"><a title="lxml.etree.QName.namespace" class="py-name" href="#" onclick="return doclink('link-6', 'namespace', 'link-5');">namespace</a></tt> <tt class="py-op">+</tt> <tt class="py-string">'}'</tt> </tt>
233 <a name="L160"></a><tt class="py-lineno">160</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
234 <a name="L161"></a><tt class="py-lineno">161</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_namespace</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
235 <a name="L162"></a><tt class="py-lineno">162</tt>  <tt class="py-line"> </tt>
236 <a name="L163"></a><tt class="py-lineno">163</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-7" class="py-name" targets="Variable lxml.etree._Element.nsmap=lxml.etree._Element-class.html#nsmap"><a title="lxml.etree._Element.nsmap" class="py-name" href="#" onclick="return doclink('link-7', 'nsmap', 'link-7');">nsmap</a></tt><tt class="py-op">:</tt> </tt>
237 <a name="L164"></a><tt class="py-lineno">164</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_nsmap</tt> <tt class="py-op">=</tt> <tt class="py-name">dict</tt><tt class="py-op">(</tt><tt id="link-8" class="py-name"><a title="lxml.etree._Element.nsmap" class="py-name" href="#" onclick="return doclink('link-8', 'nsmap', 'link-7');">nsmap</a></tt><tt class="py-op">)</tt> </tt>
238 <a name="L165"></a><tt class="py-lineno">165</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
239 <a name="L166"></a><tt class="py-lineno">166</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_nsmap</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
240 <a name="L167"></a><tt class="py-lineno">167</tt>  <tt class="py-line"> </tt>
241 <a name="L168"></a><tt class="py-lineno">168</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-9" class="py-name" targets="Method lxml.etree._BaseParser.makeelement()=lxml.etree._BaseParser-class.html#makeelement,Method lxml.etree._Element.makeelement()=lxml.etree._Element-class.html#makeelement"><a title="lxml.etree._BaseParser.makeelement
242 lxml.etree._Element.makeelement" class="py-name" href="#" onclick="return doclink('link-9', 'makeelement', 'link-9');">makeelement</a></tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
243 <a name="L169"></a><tt class="py-lineno">169</tt>  <tt class="py-line">            <tt class="py-keyword">assert</tt> <tt id="link-10" class="py-name"><a title="lxml.builder.callable" class="py-name" href="#" onclick="return doclink('link-10', 'callable', 'link-3');">callable</a></tt><tt class="py-op">(</tt><tt id="link-11" class="py-name"><a title="lxml.etree._BaseParser.makeelement
244 lxml.etree._Element.makeelement" class="py-name" href="#" onclick="return doclink('link-11', 'makeelement', 'link-9');">makeelement</a></tt><tt class="py-op">)</tt> </tt>
245 <a name="L170"></a><tt class="py-lineno">170</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_makeelement</tt> <tt class="py-op">=</tt> <tt id="link-12" class="py-name"><a title="lxml.etree._BaseParser.makeelement
246 lxml.etree._Element.makeelement" class="py-name" href="#" onclick="return doclink('link-12', 'makeelement', 'link-9');">makeelement</a></tt> </tt>
247 <a name="L171"></a><tt class="py-lineno">171</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
248 <a name="L172"></a><tt class="py-lineno">172</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_makeelement</tt> <tt class="py-op">=</tt> <tt class="py-name">ET</tt><tt class="py-op">.</tt><tt id="link-13" class="py-name" targets="Class lxml.cssselect.Element=lxml.cssselect.Element-class.html,Function lxml.etree.Element()=lxml.etree-module.html#Element,Function lxml.html.Element()=lxml.html-module.html#Element,Function lxml.objectify.Element()=lxml.objectify-module.html#Element,Method lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element()=lxml.tests.test_pyclasslookup.PyClassLookupTestCase-class.html#Element,Class xml.etree.ElementTree.Element=xml.etree.ElementTree.Element-class.html"><a title="lxml.cssselect.Element
249 lxml.etree.Element
250 lxml.html.Element
251 lxml.objectify.Element
252 lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element
253 xml.etree.ElementTree.Element" class="py-name" href="#" onclick="return doclink('link-13', 'Element', 'link-13');">Element</a></tt> </tt>
254 <a name="L173"></a><tt class="py-lineno">173</tt>  <tt class="py-line"> </tt>
255 <a name="L174"></a><tt class="py-lineno">174</tt>  <tt class="py-line">        <tt class="py-comment"># initialize type map for this element factory</tt> </tt>
256 <a name="L175"></a><tt class="py-lineno">175</tt>  <tt class="py-line"> </tt>
257 <a name="L176"></a><tt class="py-lineno">176</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">typemap</tt><tt class="py-op">:</tt> </tt>
258 <a name="L177"></a><tt class="py-lineno">177</tt>  <tt class="py-line">            <tt class="py-name">typemap</tt> <tt class="py-op">=</tt> <tt class="py-name">typemap</tt><tt class="py-op">.</tt><tt id="link-14" class="py-name" targets="Method lxml.etree.PyErrorLog.copy()=lxml.etree.PyErrorLog-class.html#copy,Method lxml.etree._BaseErrorLog.copy()=lxml.etree._BaseErrorLog-class.html#copy,Method lxml.etree._BaseParser.copy()=lxml.etree._BaseParser-class.html#copy,Method lxml.etree._ErrorLog.copy()=lxml.etree._ErrorLog-class.html#copy,Method lxml.etree._IDDict.copy()=lxml.etree._IDDict-class.html#copy,Method lxml.etree._ListErrorLog.copy()=lxml.etree._ListErrorLog-class.html#copy,Method lxml.etree._ResolverRegistry.copy()=lxml.etree._ResolverRegistry-class.html#copy,Method lxml.etree.iterparse.copy()=lxml.etree.iterparse-class.html#copy"><a title="lxml.etree.PyErrorLog.copy
259 lxml.etree._BaseErrorLog.copy
260 lxml.etree._BaseParser.copy
261 lxml.etree._ErrorLog.copy
262 lxml.etree._IDDict.copy
263 lxml.etree._ListErrorLog.copy
264 lxml.etree._ResolverRegistry.copy
265 lxml.etree.iterparse.copy" class="py-name" href="#" onclick="return doclink('link-14', 'copy', 'link-14');">copy</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
266 <a name="L178"></a><tt class="py-lineno">178</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
267 <a name="L179"></a><tt class="py-lineno">179</tt>  <tt class="py-line">            <tt class="py-name">typemap</tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-op">}</tt> </tt>
268 <a name="L180"></a><tt class="py-lineno">180</tt>  <tt class="py-line">         </tt>
269 <a name="L181"></a><tt class="py-lineno">181</tt>  <tt class="py-line">        <tt class="py-keyword">def</tt> <tt class="py-def-name">add_text</tt><tt class="py-op">(</tt><tt class="py-param">elem</tt><tt class="py-op">,</tt> <tt class="py-param">item</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
270 <a name="L182"></a><tt class="py-lineno">182</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">elem</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
271 <a name="L183"></a><tt class="py-lineno">183</tt>  <tt class="py-line">                <tt class="py-name">elem</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-15" class="py-name" targets="Variable lxml.etree._Element.tail=lxml.etree._Element-class.html#tail,Variable lxml.etree._ReadOnlyProxy.tail=lxml.etree._ReadOnlyProxy-class.html#tail,Variable xml.etree.ElementTree.Element.tail=xml.etree.ElementTree.Element-class.html#tail"><a title="lxml.etree._Element.tail
272 lxml.etree._ReadOnlyProxy.tail
273 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-15', 'tail', 'link-15');">tail</a></tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">elem</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-16" class="py-name"><a title="lxml.etree._Element.tail
274 lxml.etree._ReadOnlyProxy.tail
275 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-16', 'tail', 'link-15');">tail</a></tt> <tt class="py-keyword">or</tt> <tt class="py-string">""</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">item</tt> </tt>
276 <a name="L184"></a><tt class="py-lineno">184</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
277 <a name="L185"></a><tt class="py-lineno">185</tt>  <tt class="py-line">                <tt class="py-name">elem</tt><tt class="py-op">.</tt><tt id="link-17" class="py-name" targets="Variable lxml.etree.QName.text=lxml.etree.QName-class.html#text,Variable lxml.etree._AppendOnlyElementProxy.text=lxml.etree._AppendOnlyElementProxy-class.html#text,Variable lxml.etree._Element.text=lxml.etree._Element-class.html#text,Variable lxml.etree._Entity.text=lxml.etree._Entity-class.html#text,Variable lxml.etree._ModifyContentOnlyProxy.text=lxml.etree._ModifyContentOnlyProxy-class.html#text,Variable lxml.etree._ReadOnlyEntityProxy.text=lxml.etree._ReadOnlyEntityProxy-class.html#text,Variable lxml.etree._ReadOnlyProxy.text=lxml.etree._ReadOnlyProxy-class.html#text,Variable lxml.etree.__ContentOnlyElement.text=lxml.etree.__ContentOnlyElement-class.html#text,Variable lxml.objectify.ObjectifiedElement.text=lxml.objectify.ObjectifiedElement-class.html#text,Variable xml.etree.ElementTree.Element.text=xml.etree.ElementTree.Element-class.html#text"><a title="lxml.etree.QName.text
278 lxml.etree._AppendOnlyElementProxy.text
279 lxml.etree._Element.text
280 lxml.etree._Entity.text
281 lxml.etree._ModifyContentOnlyProxy.text
282 lxml.etree._ReadOnlyEntityProxy.text
283 lxml.etree._ReadOnlyProxy.text
284 lxml.etree.__ContentOnlyElement.text
285 lxml.objectify.ObjectifiedElement.text
286 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-17', 'text', 'link-17');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">elem</tt><tt class="py-op">.</tt><tt id="link-18" class="py-name"><a title="lxml.etree.QName.text
287 lxml.etree._AppendOnlyElementProxy.text
288 lxml.etree._Element.text
289 lxml.etree._Entity.text
290 lxml.etree._ModifyContentOnlyProxy.text
291 lxml.etree._ReadOnlyEntityProxy.text
292 lxml.etree._ReadOnlyProxy.text
293 lxml.etree.__ContentOnlyElement.text
294 lxml.objectify.ObjectifiedElement.text
295 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-18', 'text', 'link-17');">text</a></tt> <tt class="py-keyword">or</tt> <tt class="py-string">""</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">item</tt> </tt>
296 </div><a name="L186"></a><tt class="py-lineno">186</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">str</tt> <tt class="py-keyword">not</tt> <tt class="py-keyword">in</tt> <tt class="py-name">typemap</tt><tt class="py-op">:</tt> </tt>
297 <a name="L187"></a><tt class="py-lineno">187</tt>  <tt class="py-line">            <tt class="py-name">typemap</tt><tt class="py-op">[</tt><tt class="py-name">str</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">add_text</tt> </tt>
298 <a name="L188"></a><tt class="py-lineno">188</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">unicode</tt> <tt class="py-keyword">not</tt> <tt class="py-keyword">in</tt> <tt class="py-name">typemap</tt><tt class="py-op">:</tt> </tt>
299 <a name="L189"></a><tt class="py-lineno">189</tt>  <tt class="py-line">            <tt class="py-name">typemap</tt><tt class="py-op">[</tt><tt class="py-name">unicode</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">add_text</tt> </tt>
300 <a name="L190"></a><tt class="py-lineno">190</tt>  <tt class="py-line"> </tt>
301 <a name="L191"></a><tt class="py-lineno">191</tt>  <tt class="py-line">        <tt class="py-keyword">def</tt> <tt class="py-def-name">add_dict</tt><tt class="py-op">(</tt><tt class="py-param">elem</tt><tt class="py-op">,</tt> <tt class="py-param">item</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
302 <a name="L192"></a><tt class="py-lineno">192</tt>  <tt class="py-line">            <tt id="link-19" class="py-name" targets="Variable lxml.etree._Element.attrib=lxml.etree._Element-class.html#attrib,Variable lxml.etree._ProcessingInstruction.attrib=lxml.etree._ProcessingInstruction-class.html#attrib,Variable lxml.etree._ReadOnlyElementProxy.attrib=lxml.etree._ReadOnlyElementProxy-class.html#attrib,Variable lxml.etree.__ContentOnlyElement.attrib=lxml.etree.__ContentOnlyElement-class.html#attrib,Variable xml.etree.ElementTree.Element.attrib=xml.etree.ElementTree.Element-class.html#attrib"><a title="lxml.etree._Element.attrib
303 lxml.etree._ProcessingInstruction.attrib
304 lxml.etree._ReadOnlyElementProxy.attrib
305 lxml.etree.__ContentOnlyElement.attrib
306 xml.etree.ElementTree.Element.attrib" class="py-name" href="#" onclick="return doclink('link-19', 'attrib', 'link-19');">attrib</a></tt> <tt class="py-op">=</tt> <tt class="py-name">elem</tt><tt class="py-op">.</tt><tt id="link-20" class="py-name"><a title="lxml.etree._Element.attrib
307 lxml.etree._ProcessingInstruction.attrib
308 lxml.etree._ReadOnlyElementProxy.attrib
309 lxml.etree.__ContentOnlyElement.attrib
310 xml.etree.ElementTree.Element.attrib" class="py-name" href="#" onclick="return doclink('link-20', 'attrib', 'link-19');">attrib</a></tt> </tt>
311 <a name="L193"></a><tt class="py-lineno">193</tt>  <tt class="py-line">            <tt class="py-keyword">for</tt> <tt class="py-name">k</tt><tt class="py-op">,</tt> <tt id="link-21" class="py-name" targets="Variable lxml.tests.test_objectify.v=lxml.tests.test_objectify-module.html#v"><a title="lxml.tests.test_objectify.v" class="py-name" href="#" onclick="return doclink('link-21', 'v', 'link-21');">v</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">item</tt><tt class="py-op">.</tt><tt id="link-22" class="py-name" targets="Method lxml.etree._Attrib.items()=lxml.etree._Attrib-class.html#items,Method lxml.etree._Element.items()=lxml.etree._Element-class.html#items,Method lxml.etree._IDDict.items()=lxml.etree._IDDict-class.html#items,Method lxml.etree._NamespaceRegistry.items()=lxml.etree._NamespaceRegistry-class.html#items,Method lxml.etree._ReadOnlyElementProxy.items()=lxml.etree._ReadOnlyElementProxy-class.html#items,Method lxml.etree.__ContentOnlyElement.items()=lxml.etree.__ContentOnlyElement-class.html#items"><a title="lxml.etree._Attrib.items
312 lxml.etree._Element.items
313 lxml.etree._IDDict.items
314 lxml.etree._NamespaceRegistry.items
315 lxml.etree._ReadOnlyElementProxy.items
316 lxml.etree.__ContentOnlyElement.items" class="py-name" href="#" onclick="return doclink('link-22', 'items', 'link-22');">items</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
317 <a name="L194"></a><tt class="py-lineno">194</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt id="link-23" class="py-name"><a title="lxml.tests.test_objectify.v" class="py-name" href="#" onclick="return doclink('link-23', 'v', 'link-21');">v</a></tt><tt class="py-op">,</tt> <tt class="py-name">basestring</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
318 <a name="L195"></a><tt class="py-lineno">195</tt>  <tt class="py-line">                    <tt id="link-24" class="py-name"><a title="lxml.etree._Element.attrib
319 lxml.etree._ProcessingInstruction.attrib
320 lxml.etree._ReadOnlyElementProxy.attrib
321 lxml.etree.__ContentOnlyElement.attrib
322 xml.etree.ElementTree.Element.attrib" class="py-name" href="#" onclick="return doclink('link-24', 'attrib', 'link-19');">attrib</a></tt><tt class="py-op">[</tt><tt class="py-name">k</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt id="link-25" class="py-name"><a title="lxml.tests.test_objectify.v" class="py-name" href="#" onclick="return doclink('link-25', 'v', 'link-21');">v</a></tt> </tt>
323 <a name="L196"></a><tt class="py-lineno">196</tt>  <tt class="py-line">                <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
324 <a name="L197"></a><tt class="py-lineno">197</tt>  <tt class="py-line">                    <tt id="link-26" class="py-name"><a title="lxml.etree._Element.attrib
325 lxml.etree._ProcessingInstruction.attrib
326 lxml.etree._ReadOnlyElementProxy.attrib
327 lxml.etree.__ContentOnlyElement.attrib
328 xml.etree.ElementTree.Element.attrib" class="py-name" href="#" onclick="return doclink('link-26', 'attrib', 'link-19');">attrib</a></tt><tt class="py-op">[</tt><tt class="py-name">k</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">typemap</tt><tt class="py-op">[</tt><tt id="link-27" class="py-name" targets="Variable lxml.etree._LogEntry.type=lxml.etree._LogEntry-class.html#type,Variable lxml.html.InputElement.type=lxml.html.InputElement-class.html#type"><a title="lxml.etree._LogEntry.type
329 lxml.html.InputElement.type" class="py-name" href="#" onclick="return doclink('link-27', 'type', 'link-27');">type</a></tt><tt class="py-op">(</tt><tt id="link-28" class="py-name"><a title="lxml.tests.test_objectify.v" class="py-name" href="#" onclick="return doclink('link-28', 'v', 'link-21');">v</a></tt><tt class="py-op">)</tt><tt class="py-op">]</tt><tt class="py-op">(</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> <tt id="link-29" class="py-name"><a title="lxml.tests.test_objectify.v" class="py-name" href="#" onclick="return doclink('link-29', 'v', 'link-21');">v</a></tt><tt class="py-op">)</tt> </tt>
330 </div><a name="L198"></a><tt class="py-lineno">198</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">dict</tt> <tt class="py-keyword">not</tt> <tt class="py-keyword">in</tt> <tt class="py-name">typemap</tt><tt class="py-op">:</tt> </tt>
331 <a name="L199"></a><tt class="py-lineno">199</tt>  <tt class="py-line">            <tt class="py-name">typemap</tt><tt class="py-op">[</tt><tt class="py-name">dict</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">add_dict</tt> </tt>
332 <a name="L200"></a><tt class="py-lineno">200</tt>  <tt class="py-line"> </tt>
333 <a name="L201"></a><tt class="py-lineno">201</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_typemap</tt> <tt class="py-op">=</tt> <tt class="py-name">typemap</tt> </tt>
334 </div><a name="L202"></a><tt class="py-lineno">202</tt>  <tt class="py-line"> </tt>
335 <a name="ElementMaker.__call__"></a><div id="ElementMaker.__call__-def"><a name="L203"></a><tt class="py-lineno">203</tt> <a class="py-toggle" href="#" id="ElementMaker.__call__-toggle" onclick="return toggle('ElementMaker.__call__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.builder.ElementMaker-class.html#__call__">__call__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">tag</tt><tt class="py-op">,</tt> <tt class="py-op">*</tt><tt class="py-param">children</tt><tt class="py-op">,</tt> <tt class="py-op">**</tt><tt class="py-param">attrib</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
336 </div><div id="ElementMaker.__call__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ElementMaker.__call__-expanded"><a name="L204"></a><tt class="py-lineno">204</tt>  <tt class="py-line">        <tt id="link-30" class="py-name" targets="Method lxml.etree._Attrib.get()=lxml.etree._Attrib-class.html#get,Method lxml.etree._Element.get()=lxml.etree._Element-class.html#get,Method lxml.etree._IDDict.get()=lxml.etree._IDDict-class.html#get,Method lxml.etree._ProcessingInstruction.get()=lxml.etree._ProcessingInstruction-class.html#get,Method lxml.etree._ReadOnlyElementProxy.get()=lxml.etree._ReadOnlyElementProxy-class.html#get,Method lxml.etree.__ContentOnlyElement.get()=lxml.etree.__ContentOnlyElement-class.html#get"><a title="lxml.etree._Attrib.get
337 lxml.etree._Element.get
338 lxml.etree._IDDict.get
339 lxml.etree._ProcessingInstruction.get
340 lxml.etree._ReadOnlyElementProxy.get
341 lxml.etree.__ContentOnlyElement.get" class="py-name" href="#" onclick="return doclink('link-30', 'get', 'link-30');">get</a></tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_typemap</tt><tt class="py-op">.</tt><tt id="link-31" class="py-name"><a title="lxml.etree._Attrib.get
342 lxml.etree._Element.get
343 lxml.etree._IDDict.get
344 lxml.etree._ProcessingInstruction.get
345 lxml.etree._ReadOnlyElementProxy.get
346 lxml.etree.__ContentOnlyElement.get" class="py-name" href="#" onclick="return doclink('link-31', 'get', 'link-30');">get</a></tt> </tt>
347 <a name="L205"></a><tt class="py-lineno">205</tt>  <tt class="py-line"> </tt>
348 <a name="L206"></a><tt class="py-lineno">206</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_namespace</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt> <tt class="py-keyword">and</tt> <tt id="link-32" class="py-name"><a title="lxml.etree._Comment.tag
349 lxml.etree._Element.tag
350 lxml.etree._Entity.tag
351 lxml.etree._ProcessingInstruction.tag
352 lxml.etree._ReadOnlyProxy.tag
353 lxml.tests.test_xpathevaluator.tag
354 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-32', 'tag', 'link-2');">tag</a></tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-string">'{'</tt><tt class="py-op">:</tt> </tt>
355 <a name="L207"></a><tt class="py-lineno">207</tt>  <tt class="py-line">            <tt id="link-33" class="py-name"><a title="lxml.etree._Comment.tag
356 lxml.etree._Element.tag
357 lxml.etree._Entity.tag
358 lxml.etree._ProcessingInstruction.tag
359 lxml.etree._ReadOnlyProxy.tag
360 lxml.tests.test_xpathevaluator.tag
361 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-33', 'tag', 'link-2');">tag</a></tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_namespace</tt> <tt class="py-op">+</tt> <tt id="link-34" class="py-name"><a title="lxml.etree._Comment.tag
362 lxml.etree._Element.tag
363 lxml.etree._Entity.tag
364 lxml.etree._ProcessingInstruction.tag
365 lxml.etree._ReadOnlyProxy.tag
366 lxml.tests.test_xpathevaluator.tag
367 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-34', 'tag', 'link-2');">tag</a></tt> </tt>
368 <a name="L208"></a><tt class="py-lineno">208</tt>  <tt class="py-line">        <tt class="py-name">elem</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_makeelement</tt><tt class="py-op">(</tt><tt id="link-35" class="py-name"><a title="lxml.etree._Comment.tag
369 lxml.etree._Element.tag
370 lxml.etree._Entity.tag
371 lxml.etree._ProcessingInstruction.tag
372 lxml.etree._ReadOnlyProxy.tag
373 lxml.tests.test_xpathevaluator.tag
374 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-35', 'tag', 'link-2');">tag</a></tt><tt class="py-op">,</tt> <tt id="link-36" class="py-name"><a title="lxml.etree._Element.nsmap" class="py-name" href="#" onclick="return doclink('link-36', 'nsmap', 'link-7');">nsmap</a></tt><tt class="py-op">=</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_nsmap</tt><tt class="py-op">)</tt> </tt>
375 <a name="L209"></a><tt class="py-lineno">209</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-37" class="py-name"><a title="lxml.etree._Element.attrib
376 lxml.etree._ProcessingInstruction.attrib
377 lxml.etree._ReadOnlyElementProxy.attrib
378 lxml.etree.__ContentOnlyElement.attrib
379 xml.etree.ElementTree.Element.attrib" class="py-name" href="#" onclick="return doclink('link-37', 'attrib', 'link-19');">attrib</a></tt><tt class="py-op">:</tt> </tt>
380 <a name="L210"></a><tt class="py-lineno">210</tt>  <tt class="py-line">            <tt id="link-38" class="py-name"><a title="lxml.etree._Attrib.get
381 lxml.etree._Element.get
382 lxml.etree._IDDict.get
383 lxml.etree._ProcessingInstruction.get
384 lxml.etree._ReadOnlyElementProxy.get
385 lxml.etree.__ContentOnlyElement.get" class="py-name" href="#" onclick="return doclink('link-38', 'get', 'link-30');">get</a></tt><tt class="py-op">(</tt><tt class="py-name">dict</tt><tt class="py-op">)</tt><tt class="py-op">(</tt><tt class="py-name">elem</tt><tt class="py-op">,</tt> <tt id="link-39" class="py-name"><a title="lxml.etree._Element.attrib
386 lxml.etree._ProcessingInstruction.attrib
387 lxml.etree._ReadOnlyElementProxy.attrib
388 lxml.etree.__ContentOnlyElement.attrib
389 xml.etree.ElementTree.Element.attrib" class="py-name" href="#" onclick="return doclink('link-39', 'attrib', 'link-19');">attrib</a></tt><tt class="py-op">)</tt> </tt>
390 <a name="L211"></a><tt class="py-lineno">211</tt>  <tt class="py-line"> </tt>
391 <a name="L212"></a><tt class="py-lineno">212</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">item</tt> <tt class="py-keyword">in</tt> <tt class="py-name">children</tt><tt class="py-op">:</tt> </tt>
392 <a name="L213"></a><tt class="py-lineno">213</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt id="link-40" class="py-name"><a title="lxml.builder.callable" class="py-name" href="#" onclick="return doclink('link-40', 'callable', 'link-3');">callable</a></tt><tt class="py-op">(</tt><tt class="py-name">item</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
393 <a name="L214"></a><tt class="py-lineno">214</tt>  <tt class="py-line">                <tt class="py-name">item</tt> <tt class="py-op">=</tt> <tt class="py-name">item</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
394 <a name="L215"></a><tt class="py-lineno">215</tt>  <tt class="py-line">            <tt class="py-name">t</tt> <tt class="py-op">=</tt> <tt id="link-41" class="py-name"><a title="lxml.etree._Attrib.get
395 lxml.etree._Element.get
396 lxml.etree._IDDict.get
397 lxml.etree._ProcessingInstruction.get
398 lxml.etree._ReadOnlyElementProxy.get
399 lxml.etree.__ContentOnlyElement.get" class="py-name" href="#" onclick="return doclink('link-41', 'get', 'link-30');">get</a></tt><tt class="py-op">(</tt><tt id="link-42" class="py-name"><a title="lxml.etree._LogEntry.type
400 lxml.html.InputElement.type" class="py-name" href="#" onclick="return doclink('link-42', 'type', 'link-27');">type</a></tt><tt class="py-op">(</tt><tt class="py-name">item</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
401 <a name="L216"></a><tt class="py-lineno">216</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">t</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
402 <a name="L217"></a><tt class="py-lineno">217</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ET</tt><tt class="py-op">.</tt><tt id="link-43" class="py-name" targets="Function lxml.etree.iselement()=lxml.etree-module.html#iselement"><a title="lxml.etree.iselement" class="py-name" href="#" onclick="return doclink('link-43', 'iselement', 'link-43');">iselement</a></tt><tt class="py-op">(</tt><tt class="py-name">item</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
403 <a name="L218"></a><tt class="py-lineno">218</tt>  <tt class="py-line">                    <tt class="py-name">elem</tt><tt class="py-op">.</tt><tt id="link-44" class="py-name" targets="Method lxml.etree._AppendOnlyElementProxy.append()=lxml.etree._AppendOnlyElementProxy-class.html#append,Method lxml.etree._Element.append()=lxml.etree._Element-class.html#append,Method lxml.etree._OpaqueDocumentWrapper.append()=lxml.etree._OpaqueDocumentWrapper-class.html#append,Method lxml.etree.__ContentOnlyElement.append()=lxml.etree.__ContentOnlyElement-class.html#append"><a title="lxml.etree._AppendOnlyElementProxy.append
404 lxml.etree._Element.append
405 lxml.etree._OpaqueDocumentWrapper.append
406 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-44', 'append', 'link-44');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">item</tt><tt class="py-op">)</tt> </tt>
407 <a name="L219"></a><tt class="py-lineno">219</tt>  <tt class="py-line">                    <tt class="py-keyword">continue</tt> </tt>
408 <a name="L220"></a><tt class="py-lineno">220</tt>  <tt class="py-line">                <tt class="py-keyword">raise</tt> <tt class="py-name">TypeError</tt><tt class="py-op">(</tt><tt class="py-string">"bad argument type: %r"</tt> <tt class="py-op">%</tt> <tt class="py-name">item</tt><tt class="py-op">)</tt> </tt>
409 <a name="L221"></a><tt class="py-lineno">221</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
410 <a name="L222"></a><tt class="py-lineno">222</tt>  <tt class="py-line">                <tt id="link-45" class="py-name"><a title="lxml.tests.test_objectify.v" class="py-name" href="#" onclick="return doclink('link-45', 'v', 'link-21');">v</a></tt> <tt class="py-op">=</tt> <tt class="py-name">t</tt><tt class="py-op">(</tt><tt class="py-name">elem</tt><tt class="py-op">,</tt> <tt class="py-name">item</tt><tt class="py-op">)</tt> </tt>
411 <a name="L223"></a><tt class="py-lineno">223</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt id="link-46" class="py-name"><a title="lxml.tests.test_objectify.v" class="py-name" href="#" onclick="return doclink('link-46', 'v', 'link-21');">v</a></tt><tt class="py-op">:</tt> </tt>
412 <a name="L224"></a><tt class="py-lineno">224</tt>  <tt class="py-line">                    <tt id="link-47" class="py-name"><a title="lxml.etree._Attrib.get
413 lxml.etree._Element.get
414 lxml.etree._IDDict.get
415 lxml.etree._ProcessingInstruction.get
416 lxml.etree._ReadOnlyElementProxy.get
417 lxml.etree.__ContentOnlyElement.get" class="py-name" href="#" onclick="return doclink('link-47', 'get', 'link-30');">get</a></tt><tt class="py-op">(</tt><tt id="link-48" class="py-name"><a title="lxml.etree._LogEntry.type
418 lxml.html.InputElement.type" class="py-name" href="#" onclick="return doclink('link-48', 'type', 'link-27');">type</a></tt><tt class="py-op">(</tt><tt id="link-49" class="py-name"><a title="lxml.tests.test_objectify.v" class="py-name" href="#" onclick="return doclink('link-49', 'v', 'link-21');">v</a></tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">(</tt><tt class="py-name">elem</tt><tt class="py-op">,</tt> <tt id="link-50" class="py-name"><a title="lxml.tests.test_objectify.v" class="py-name" href="#" onclick="return doclink('link-50', 'v', 'link-21');">v</a></tt><tt class="py-op">)</tt> </tt>
419 <a name="L225"></a><tt class="py-lineno">225</tt>  <tt class="py-line"> </tt>
420 <a name="L226"></a><tt class="py-lineno">226</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">elem</tt> </tt>
421 </div><a name="L227"></a><tt class="py-lineno">227</tt>  <tt class="py-line"> </tt>
422 <a name="ElementMaker.__getattr__"></a><div id="ElementMaker.__getattr__-def"><a name="L228"></a><tt class="py-lineno">228</tt> <a class="py-toggle" href="#" id="ElementMaker.__getattr__-toggle" onclick="return toggle('ElementMaker.__getattr__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.builder.ElementMaker-class.html#__getattr__">__getattr__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">tag</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
423 </div><div id="ElementMaker.__getattr__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ElementMaker.__getattr__-expanded"><a name="L229"></a><tt class="py-lineno">229</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">partial</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">,</tt> <tt id="link-51" class="py-name"><a title="lxml.etree._Comment.tag
424 lxml.etree._Element.tag
425 lxml.etree._Entity.tag
426 lxml.etree._ProcessingInstruction.tag
427 lxml.etree._ReadOnlyProxy.tag
428 lxml.tests.test_xpathevaluator.tag
429 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-51', 'tag', 'link-2');">tag</a></tt><tt class="py-op">)</tt> </tt>
430 </div></div><a name="L230"></a><tt class="py-lineno">230</tt>  <tt class="py-line"> </tt>
431 <a name="L231"></a><tt class="py-lineno">231</tt>  <tt class="py-line"><tt class="py-comment"># create factory object</tt> </tt>
432 <a name="L232"></a><tt class="py-lineno">232</tt>  <tt class="py-line"><tt id="link-52" class="py-name" targets="Variable lxml.builder.E=lxml.builder-module.html#E,Variable lxml.html.builder.E=lxml.html.builder-module.html#E,Variable lxml.objectify.E=lxml.objectify-module.html#E"><a title="lxml.builder.E
433 lxml.html.builder.E
434 lxml.objectify.E" class="py-name" href="#" onclick="return doclink('link-52', 'E', 'link-52');">E</a></tt> <tt class="py-op">=</tt> <tt id="link-53" class="py-name" targets="Class lxml.builder.ElementMaker=lxml.builder.ElementMaker-class.html,Class lxml.objectify.ElementMaker=lxml.objectify.ElementMaker-class.html"><a title="lxml.builder.ElementMaker
435 lxml.objectify.ElementMaker" class="py-name" href="#" onclick="return doclink('link-53', 'ElementMaker', 'link-53');">ElementMaker</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
436 <a name="L233"></a><tt class="py-lineno">233</tt>  <tt class="py-line"> </tt><script type="text/javascript">
437 <!--
438 expandto(location.href);
439 // -->
440 </script>
441 </pre>
442 <br />
443 <!-- ==================== NAVIGATION BAR ==================== -->
444 <table class="navbar" border="0" width="100%" cellpadding="0"
445        bgcolor="#a0c0ff" cellspacing="0">
446   <tr valign="middle">
447   <!-- Home link -->
448       <th>&nbsp;&nbsp;&nbsp;<a
449         href="lxml-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
450
451   <!-- Tree link -->
452       <th>&nbsp;&nbsp;&nbsp;<a
453         href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
454
455   <!-- Index link -->
456       <th>&nbsp;&nbsp;&nbsp;<a
457         href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
458
459   <!-- Help link -->
460       <th>&nbsp;&nbsp;&nbsp;<a
461         href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
462
463   <!-- Project homepage -->
464       <th class="navbar" align="right" width="100%">
465         <table border="0" cellpadding="0" cellspacing="0">
466           <tr><th class="navbar" align="center"
467             ><a class="navbar" target="_top" href="/">lxml API</a></th>
468           </tr></table></th>
469   </tr>
470 </table>
471 <table border="0" cellpadding="0" cellspacing="0" width="100%%">
472   <tr>
473     <td align="left" class="footer">
474     Generated by Epydoc 3.0.1 on Tue Jul 31 10:14:22 2012
475     </td>
476     <td align="right" class="footer">
477       <a target="mainFrame" href="http://epydoc.sourceforge.net"
478         >http://epydoc.sourceforge.net</a>
479     </td>
480   </tr>
481 </table>
482
483 <script type="text/javascript">
484   <!--
485   // Private objects are initially displayed (because if
486   // javascript is turned off then we want them to be
487   // visible); but by default, we want to hide them.  So hide
488   // them unless we have a cookie that says to show them.
489   checkCookie();
490   // -->
491 </script>
492 </body>
493 </html>