diff --git a/doc/DOM.html b/doc/DOM.html index 7c74dc0e..e78e9c59 100644 --- a/doc/DOM.html +++ b/doc/DOM.html @@ -3,11 +3,11 @@ DOM Principles diff --git a/doc/FAQ.html b/doc/FAQ.html index 3b3731b4..8aa8959c 100644 --- a/doc/FAQ.html +++ b/doc/FAQ.html @@ -3,11 +3,11 @@ FAQ diff --git a/doc/XMLinfo.html b/doc/XMLinfo.html index d3e03b6c..140753c4 100644 --- a/doc/XMLinfo.html +++ b/doc/XMLinfo.html @@ -3,11 +3,11 @@ XML diff --git a/doc/XSLT.html b/doc/XSLT.html index 9abdd65a..6dfd2bda 100644 --- a/doc/XSLT.html +++ b/doc/XSLT.html @@ -3,11 +3,11 @@ XSLT diff --git a/doc/architecture.html b/doc/architecture.html index f66fe480..c057f30f 100644 --- a/doc/architecture.html +++ b/doc/architecture.html @@ -3,11 +3,11 @@ libxml architecture diff --git a/doc/bugs.html b/doc/bugs.html index b4b79108..e1a105dd 100644 --- a/doc/bugs.html +++ b/doc/bugs.html @@ -3,11 +3,11 @@ Reporting bugs and getting help diff --git a/doc/catalog.html b/doc/catalog.html index 93389a1b..60fbec72 100644 --- a/doc/catalog.html +++ b/doc/catalog.html @@ -3,11 +3,11 @@ Catalog support diff --git a/doc/contribs.html b/doc/contribs.html index da48ad3f..d3ad65b0 100644 --- a/doc/contribs.html +++ b/doc/contribs.html @@ -3,11 +3,11 @@ Contributions diff --git a/doc/docs.html b/doc/docs.html index 571ca47b..2d278beb 100644 --- a/doc/docs.html +++ b/doc/docs.html @@ -3,11 +3,11 @@ Documentation diff --git a/doc/downloads.html b/doc/downloads.html index e8519c31..749bf4d2 100644 --- a/doc/downloads.html +++ b/doc/downloads.html @@ -3,11 +3,11 @@ Downloads diff --git a/doc/encoding.html b/doc/encoding.html index 16e05d51..2e2aa23d 100644 --- a/doc/encoding.html +++ b/doc/encoding.html @@ -3,11 +3,11 @@ Encodings support diff --git a/doc/entities.html b/doc/entities.html index fb9c8068..337995c1 100644 --- a/doc/entities.html +++ b/doc/entities.html @@ -3,11 +3,11 @@ Entities or no entities diff --git a/doc/example.html b/doc/example.html index 6c27f97c..df8e9ed5 100644 --- a/doc/example.html +++ b/doc/example.html @@ -3,11 +3,11 @@ A real example diff --git a/doc/help.html b/doc/help.html index 303c4f16..e78f39ce 100644 --- a/doc/help.html +++ b/doc/help.html @@ -3,11 +3,11 @@ How to help diff --git a/doc/index.html b/doc/index.html index f6579e06..14ac3f10 100644 --- a/doc/index.html +++ b/doc/index.html @@ -3,11 +3,11 @@ The XML C library for Gnome diff --git a/doc/interface.html b/doc/interface.html index 27cce3b0..9038022b 100644 --- a/doc/interface.html +++ b/doc/interface.html @@ -3,11 +3,11 @@ The SAX interface diff --git a/doc/intro.html b/doc/intro.html index f256d6d6..953c8ac4 100644 --- a/doc/intro.html +++ b/doc/intro.html @@ -3,11 +3,11 @@ Introduction diff --git a/doc/library.html b/doc/library.html index 21de9ed3..0daa044c 100644 --- a/doc/library.html +++ b/doc/library.html @@ -3,11 +3,11 @@ The parser interfaces diff --git a/doc/namespaces.html b/doc/namespaces.html index 409d1436..98198e34 100644 --- a/doc/namespaces.html +++ b/doc/namespaces.html @@ -3,11 +3,11 @@ Namespaces diff --git a/doc/news.html b/doc/news.html index c2c2be33..a26a62c6 100644 --- a/doc/news.html +++ b/doc/news.html @@ -3,11 +3,11 @@ News diff --git a/doc/python.html b/doc/python.html index 730c45e1..359f060b 100644 --- a/doc/python.html +++ b/doc/python.html @@ -3,11 +3,12 @@ Python and bindings @@ -127,7 +128,7 @@ the python/tests directory. Here are some excepts from those tests:

tst.py:

This is a basic test of the file interface and DOM navigation:

-
import libxml2
+import libxml2
 
 doc = libxml2.parseFile("tst.xml")
 if doc.name != "tst.xml":
@@ -141,7 +142,7 @@ child = root.children
 if child.name != "foo":
     print "child.name failed"
     sys.exit(1)
-doc.freeDoc()
+doc.freeDoc()

The Python module is called libxml2, parseFile is the equivalent of xmlParseFile (most of the bindings are automatically generated, and the xml prefix is removed and the casing convention are kept). All node seen at the @@ -174,7 +175,7 @@ collected.

validate.py:

This test check the validation interfaces and redirection of error messages:

-
import libxml2
+import libxml2
 
 #desactivate error messages from the validation
 def noerr(ctx, str):
@@ -189,7 +190,7 @@ doc = ctxt.doc()
 valid = ctxt.isValid()
 doc.freeDoc()
 if valid != 0:
-    print "validity chec failed"
+ print "validity chec failed"

The first thing to notice is the call to registerErrorHandler(), it defines a new error handler global to the library. It is used to avoid seeing the error messages when trying to validate the invalid document.

@@ -203,13 +204,13 @@ best to get a complete view of what methods are supported is to look at the libxml2.py module containing all the wrappers.

push.py:

This test show how to activate the push parser interface:

-
import libxml2
+import libxml2
 
 ctxt = libxml2.createPushParser(None, "<foo", 4, "test.xml")
 ctxt.parseChunk("/>", 2, 1)
 doc = ctxt.doc()
 
-doc.freeDoc()
+doc.freeDoc()

The context is created with a speciall call based on the xmlCreatePushParser() from the C library. The first argument is an optional SAX callback object, then the initial set of data, the lenght and the name of @@ -220,7 +221,7 @@ setting the thrird argument terminate to 1.

this test show the use of the event based parsing interfaces. In this case the parser does not build a document, but provides callback information as the parser makes progresses analyzing the data being provided:

-
import libxml2
+import libxml2
 log = ""
 
 class callback:
@@ -267,7 +268,7 @@ ctxt.parseChunk(chunk, len(chunk), 1)
 reference = "startDocument:startElement foo {'url': 'tst'}:characters: bar:endElement foo:endDocument:"
 if log != reference:
     print "Error got: %s" % log
-    print "Exprected: %s" % reference
+ print "Exprected: %s" % reference

The key object in that test is the handler, it provides a number of entry points which can be called by the parser as it makes progresses to indicate the information set obtained. The full set of callback is larger than what @@ -280,7 +281,7 @@ single character call even though the string "bar" is passed to the pa from 2 different call to parseChunk()

xpath.py:

This is a basic test of XPath warppers support

-
import libxml2
+import libxml2
 
 doc = libxml2.parseFile("tst.xml")
 ctxt = doc.xpathNewContext()
@@ -292,7 +293,7 @@ if res[0].name != "doc" or res[1].name != "foo":
     print "xpath query: wrong node set value"
     sys.exit(1)
 doc.freeDoc()
-ctxt.xpathFreeContext()
+ctxt.xpathFreeContext()

This test parses a file, then create an XPath context to evaluate XPath expression on it. The xpathEval() method execute an XPath query and returns the result mapped in a Python way. String and numbers are natively converted, @@ -303,7 +304,7 @@ the document must be freed after the result of the query is used.

xpathext.py:

This test shows how to extend the XPath engine with functions written in python:

-
import libxml2
+import libxml2
 
 def foo(ctx, x):
     return x + 1
@@ -315,13 +316,13 @@ res = ctxt.xpathEval("foo(1)")
 if res != 2:
     print "xpath extension failure"
 doc.freeDoc()
-ctxt.xpathFreeContext()
+ctxt.xpathFreeContext()

Note how the extension function is registered with the context (but that part is not yet finalized, ths may change slightly in the future).

tstxpath.py:

This test is similar to the previousone but shows how the extension function can access the XPath evaluation context:

-
def foo(ctx, x):
+def foo(ctx, x):
     global called
 
     #
@@ -330,23 +331,23 @@ function can access the XPath evaluation context:

pctxt = libxml2.xpathParserContext(_obj=ctx) ctxt = pctxt.context() called = ctxt.function() - return x + 1
+ return x + 1

All the interfaces around the XPath parser(or rather evaluation) context are not finalized, but it should be sufficient to do contextual work at the evaluation point.

Memory debugging:

last but not least, all tests starts with the following prologue:

-
#memory debug specific
+#memory debug specific
 libxml2.debugMemory(1)
-
+

and ends with the following epilogue:

-
#memory debug specific
+#memory debug specific
 libxml2.cleanupParser()
 if libxml2.debugMemory(1) == 0:
     print "OK"
 else:
     print "Memory leak %d bytes" % (libxml2.debugMemory(1))
-    libxml2.dumpMemory()
+ libxml2.dumpMemory()

Those activate the memory debugging interface of libxml2 where all alloacted block in the library are tracked. The prologue then cleans up the library state and checks that all allocated memory has been freed. If not it diff --git a/doc/site.xsl b/doc/site.xsl index 24495c6f..2591cf51 100644 --- a/doc/site.xsl +++ b/doc/site.xsl @@ -213,11 +213,11 @@ --> diff --git a/doc/threads.html b/doc/threads.html index 6201c727..b7fd83d7 100644 --- a/doc/threads.html +++ b/doc/threads.html @@ -3,11 +3,11 @@ Thread safety diff --git a/doc/tree.html b/doc/tree.html index e32f4735..09ff6d13 100644 --- a/doc/tree.html +++ b/doc/tree.html @@ -3,11 +3,11 @@ The tree output diff --git a/doc/upgrade.html b/doc/upgrade.html index 5965662d..b7e48ab4 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -3,11 +3,11 @@ Upgrading 1.x code diff --git a/doc/xmldtd.html b/doc/xmldtd.html index fde7953c..70a9ca0d 100644 --- a/doc/xmldtd.html +++ b/doc/xmldtd.html @@ -3,11 +3,11 @@ Validation & DTDs diff --git a/doc/xmlio.html b/doc/xmlio.html index 43cfbad5..2f59de36 100644 --- a/doc/xmlio.html +++ b/doc/xmlio.html @@ -3,11 +3,11 @@ I/O Interfaces diff --git a/doc/xmlmem.html b/doc/xmlmem.html index fd4c050b..a18b3aba 100644 --- a/doc/xmlmem.html +++ b/doc/xmlmem.html @@ -3,11 +3,11 @@ Memory Management