libxml2dom

docs/libxml2macro.html

345:0a3f4b5a51d7
2008-09-14 Paul Boddie Added some XML-RPC methods and properties to the SOAP implementation. Moved the Python value emulation classes into the new libxml2dom.values module. Renamed the SOAP test program. Updated release information.
     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">     2 <html xmlns="http://www.w3.org/1999/xhtml">     3 <head>     4   <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">     5   <title>libxml2macro</title>     6   <meta name="generator"     7  content="amaya 8.1a, see http://www.w3.org/Amaya/">     8   <link href="styles.css" rel="stylesheet" type="text/css">     9 </head>    10 <body>    11 <h1>libxml2macro</h1>    12 <p>The libxml2macro tool and accompanying libraries (<code>libxml2dom.macrolib</code>)    13 provide and experimental mechanism for writing normal DOM-style code    14 (with node objects) and being able to transform such code into direct    15 calls and accesses to the low-level libxml2mod API. Since libxml2dom    16 now makes use of these libraries, and since the objects created at the    17 libxml2dom level do not necessarily introduce a huge time or memory    18 overhead, this mechanism is now more an experimental curiosity than    19 anything of practical use. Moreover, the generated code does not    20 attempt to clean up after libxml2, potentially introducing memory leaks    21 into programs.</p>    22 <h2>Using libxml2macro</h2>    23 <p>The libxml2macro approach is as follows:</p>    24 <ul>    25   <li>Write code using the PyXML-inspired DOM-style API, but giving    26 node variables and attributes a distinct prefix.</li>    27   <li>Run the supplied tool <code>libxml2macro.py</code> on the source    28 file.</li>    29   <li>Invoke the compiled module directly or import it into programs as    30 usual.</li>    31 </ul>    32 <p>A description of the process is given in the <code>README.txt</code>    33 file    34 within the source code distribution. However, what libxml2macro does is    35 to    36 take code like this...</p>    37 <pre>for my_node in my_element.childNodes:<br>    if my_node.nodeType == TEXT_NODE:<br>        print my_node.nodeValue</pre>    38 <p>...and to transform it into something more or less like this    39 (although in    40 practice the actual libxml2mod calls are provided in a library,    41 although more    42 aggressive transformations could result in something actually like    43 this):</p>    44 <pre>for my_node in libxml2mod.children(my_element):<br>    if libxml2mod.type(my_node) == "text":<br>        print libxml2mod.xmlNodeGetContent(my_node)</pre>    45 <p>The result is that developers can still write DOM-style code but not    46 be    47 penalised for the object-related overhead that such an approach    48 typically    49 incurs.</p>    50 </body>    51 </html>