1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/docs/libxml2macro.html Sun May 15 17:05:27 2005 +0000
1.3 @@ -0,0 +1,51 @@
1.4 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
1.5 +<html xmlns="http://www.w3.org/1999/xhtml">
1.6 +<head>
1.7 + <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
1.8 + <title>libxml2macro</title>
1.9 + <meta name="generator"
1.10 + content="amaya 8.1a, see http://www.w3.org/Amaya/">
1.11 + <link href="styles.css" rel="stylesheet" type="text/css">
1.12 +</head>
1.13 +<body>
1.14 +<h1>libxml2macro</h1>
1.15 +<p>The libxml2macro tool and accompanying libraries (<code>libxml2dom.macrolib</code>)
1.16 +provide and experimental mechanism for writing normal DOM-style code
1.17 +(with node objects) and being able to transform such code into direct
1.18 +calls and accesses to the low-level libxml2mod API. Since libxml2dom
1.19 +now makes use of these libraries, and since the objects created at the
1.20 +libxml2dom level do not necessarily introduce a huge time or memory
1.21 +overhead, this mechanism is now more an experimental curiosity than
1.22 +anything of practical use. Moreover, the generated code does not
1.23 +attempt to clean up after libxml2, potentially introducing memory leaks
1.24 +into programs.</p>
1.25 +<h2>Using libxml2macro</h2>
1.26 +<p>The libxml2macro approach is as follows:</p>
1.27 +<ul>
1.28 + <li>Write code using the PyXML-inspired DOM-style API, but giving
1.29 +node variables and attributes a distinct prefix.</li>
1.30 + <li>Run the supplied tool <code>libxml2macro.py</code> on the source
1.31 +file.</li>
1.32 + <li>Invoke the compiled module directly or import it into programs as
1.33 +usual.</li>
1.34 +</ul>
1.35 +<p>A description of the process is given in the <code>README.txt</code>
1.36 +file
1.37 +within the source code distribution. However, what libxml2macro does is
1.38 +to
1.39 +take code like this...</p>
1.40 +<pre>for my_node in my_element.childNodes:<br> if my_node.nodeType == TEXT_NODE:<br> print my_node.nodeValue</pre>
1.41 +<p>...and to transform it into something more or less like this
1.42 +(although in
1.43 +practice the actual libxml2mod calls are provided in a library,
1.44 +although more
1.45 +aggressive transformations could result in something actually like
1.46 +this):</p>
1.47 +<pre>for my_node in libxml2mod.children(my_element):<br> if libxml2mod.type(my_node) == "text":<br> print libxml2mod.xmlNodeGetContent(my_node)</pre>
1.48 +<p>The result is that developers can still write DOM-style code but not
1.49 +be
1.50 +penalised for the object-related overhead that such an approach
1.51 +typically
1.52 +incurs.</p>
1.53 +</body>
1.54 +</html>