[Lxml-checkins] r44172 - in lxml/branch/lxml-1.3: benchmark doc doc/html src/lxml src/lxml/tests

scoder at codespeak.net scoder at codespeak.net
Tue Jun 12 18:06:29 CEST 2007


Author: scoder
Date: Tue Jun 12 18:06:23 2007
New Revision: 44172

Modified:
   lxml/branch/lxml-1.3/benchmark/bench_xpath.py
   lxml/branch/lxml-1.3/doc/FAQ.txt
   lxml/branch/lxml-1.3/doc/html/style.css
   lxml/branch/lxml-1.3/src/lxml/etree.pyx
   lxml/branch/lxml-1.3/src/lxml/python.pxd
   lxml/branch/lxml-1.3/src/lxml/tests/test_etree.py
   lxml/branch/lxml-1.3/src/lxml/tests/test_objectify.py
   lxml/branch/lxml-1.3/src/lxml/tests/test_xpathevaluator.py
   lxml/branch/lxml-1.3/src/lxml/tree.pxd
Log:
merged in revs 40611:41008 from trunk

Modified: lxml/branch/lxml-1.3/benchmark/bench_xpath.py
==============================================================================
--- lxml/branch/lxml-1.3/benchmark/bench_xpath.py	(original)
+++ lxml/branch/lxml-1.3/benchmark/bench_xpath.py	Tue Jun 12 18:06:23 2007
@@ -34,7 +34,7 @@
             child.xpath("./*[0]")
 
     @onlylib('lxe')
-    def bench_xpath_extensions_old(self, root):
+    def bench_xpath_old_extensions(self, root):
         def return_child(_, element):
             if element:
                 return element[0]
@@ -45,5 +45,21 @@
         for child in root:
             xpath(child)
 
+    @onlylib('lxe')
+    def bench_xpath_extensions(self, root):
+        def return_child(_, element):
+            if element:
+                return element[0]
+            else:
+                return ()
+        self.etree.FunctionNamespace("test")["t"] = return_child
+
+        try:
+            xpath = self.etree.XPath("test:t(.)", {"test":"test"})
+            for child in root:
+                xpath(child)
+        finally:
+            del self.etree.FunctionNamespace("test")["t"]
+
 if __name__ == '__main__':
     benchbase.main(XPathBenchMark)

Modified: lxml/branch/lxml-1.3/doc/FAQ.txt
==============================================================================
--- lxml/branch/lxml-1.3/doc/FAQ.txt	(original)
+++ lxml/branch/lxml-1.3/doc/FAQ.txt	Tue Jun 12 18:06:23 2007
@@ -12,10 +12,11 @@
    1  General Questions
      1.1  Is there a tutorial?
      1.2  Where can I find more documentation about lxml?
-     1.3  Where are the Windows binaries?
-     1.4  What is the difference between lxml.etree and lxml.objectify?
-     1.5  Why is my application so slow?
-     1.6  Why do I get errors about missing UCS4 symbols when installing lxml?
+     1.3  What standards does lxml implement?
+     1.4  Where are the Windows binaries?
+     1.5  What is the difference between lxml.etree and lxml.objectify?
+     1.6  Why is my application so slow?
+     1.7  Why do I get errors about missing UCS4 symbols when installing lxml?
    2  Bugs
      2.1  My application crashes! Why does lxml.etree do that?
      2.2  I think I have found a bug in lxml. What should I do?
@@ -64,6 +65,24 @@
 .. _`the web page`:    http://codespeak.net/lxml/#documentation
 
 
+What standards does lxml implement?
+-----------------------------------
+
+The compliance to XML Standards depends on the support in libxml2 and libxslt.
+Here is a quote from `http://xmlsoft.org/`:
+
+  In most cases libxml2 tries to implement the specifications in a relatively
+  strictly compliant way. As of release 2.4.16, libxml2 passed all 1800+ tests
+  from the OASIS XML Tests Suite.
+
+lxml currently supports libxml2 2.6.16 or later, which has even better support
+for various XML standards.  Some of the more important ones are: HTML, XML
+namespaces, XPath, XInclude, XSLT, XML catalogs, canonical XML, RelaxNG,
+XML:ID.  Support for XML Schema and Schematron is currently incomplete in
+libxml2, but is mostly usable and still being worked on.  libxml2 also
+supports loading documents through HTTP and FTP.
+
+
 Where are the Windows binaries?
 -------------------------------
 

Modified: lxml/branch/lxml-1.3/doc/html/style.css
==============================================================================
--- lxml/branch/lxml-1.3/doc/html/style.css	(original)
+++ lxml/branch/lxml-1.3/doc/html/style.css	Tue Jun 12 18:06:23 2007
@@ -67,10 +67,12 @@
     font-size: 130%;
 }
 
-div.sidemenu ul.menu.current > li {
-    color: orange;
-    border: groove orange;
-    background-color: #FFFACA;
+div.sidemenu ul.menu.current li {
+    color: #CC0000;
+}
+
+div.sidemenu ul.menu.current > li > a {
+    color: #CC0000;
 }
 
 div.sidemenu ul.menu.current ul.submenu {
@@ -85,12 +87,13 @@
 div.sidemenu ul.menu.foreign li.menu:hover ul.submenu {
     display: block;
     position: absolute;
-    border: groove orange;
+    border: groove #990000;
     padding: 1ex 1ex 1ex 3ex;
     margin-top: 0px;
     margin-left: 4em;
     margin-right: -20em;
-    background-color: #FFFACA;
+    color: #990000;
+    background-color: white;
 }
 
 div.sidemenu ul.submenu {
@@ -121,7 +124,7 @@
 @media screen {
     div.section > h1 > a:before {
         margin-left: -2ex;
-        color: orange;
+        color: #CC0000;
         content: "\00BB" " ";
     }
 }

Modified: lxml/branch/lxml-1.3/src/lxml/etree.pyx
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/etree.pyx	(original)
+++ lxml/branch/lxml-1.3/src/lxml/etree.pyx	Tue Jun 12 18:06:23 2007
@@ -673,6 +673,24 @@
             return None
 
     # not in ElementTree, read-only
+    property sourceline:
+        """Original line number as found by the parser or None if unknown.
+        """
+        def __get__(self):
+            cdef long line
+            line = tree.xmlGetLineNo(self._c_node)
+            if line > 0:
+                return line
+            else:
+                return None
+
+        def __set__(self, line):
+            if line < 0:
+                self._c_node.line = 0
+            else:
+                self._c_node.line = line
+
+    # not in ElementTree, read-only
     property nsmap:
         """Namespace prefix->URI mapping known in the context of this Element.
         """

Modified: lxml/branch/lxml-1.3/src/lxml/python.pxd
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/python.pxd	(original)
+++ lxml/branch/lxml-1.3/src/lxml/python.pxd	Tue Jun 12 18:06:23 2007
@@ -44,7 +44,8 @@
     cdef int PyList_Append(object l, object obj) except -1
     cdef int PyList_Reverse(object l) except -1
     cdef int PyList_Insert(object l, Py_ssize_t index, object o) except -1
-    cdef object PyList_AsTuple(object o)
+    cdef object PyList_AsTuple(object l)
+    cdef void PyList_Clear(object l)
 
     cdef int PyDict_SetItemString(object d, char* key, object value) except -1
     cdef int PyDict_SetItem(object d, object key, object value) except -1

Modified: lxml/branch/lxml-1.3/src/lxml/tests/test_etree.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/test_etree.py	(original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/test_etree.py	Tue Jun 12 18:06:23 2007
@@ -1119,6 +1119,37 @@
             ["tail0", "tail1", "tail2", "TAIL0", "TAIL1", "TAIL2"],
             [ el.tail for el in root ])
 
+    def test_sourceline_XML(self):
+        XML = self.etree.XML
+        root = XML('''<?xml version="1.0"?>
+        <root><test>
+
+        <bla/></test>
+        </root>
+        ''')
+
+        self.assertEquals(
+            [2, 2, 4],
+            [ el.sourceline for el in root.getiterator() ])
+
+    def test_sourceline_parse(self):
+        parse = self.etree.parse
+        tree = parse(fileInTestDir('test_xinclude.xml'))
+
+        self.assertEquals(
+            [1, 2, 3],
+            [ el.sourceline for el in tree.getiterator() ])
+
+    def test_sourceline_element(self):
+        Element = self.etree.Element
+        SubElement = self.etree.SubElement
+        el = Element("test")
+        self.assertEquals(None, el.sourceline)
+
+        child = SubElement(el, "test")
+        self.assertEquals(None, el.sourceline)
+        self.assertEquals(None, child.sourceline)
+
     def test_docinfo_public(self):
         etree = self.etree
         xml_header = '<?xml version="1.0" encoding="ascii"?>'

Modified: lxml/branch/lxml-1.3/src/lxml/tests/test_objectify.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/test_objectify.py	(original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/test_objectify.py	Tue Jun 12 18:06:23 2007
@@ -1,10 +1,7 @@
 # -*- coding: utf-8 -*-
 
 """
-Tests specific to the extended etree API
-
-Tests that apply to the general ElementTree API should go into
-test_elementtree
+Tests specific to the lxml.objectify API
 """
 
 
@@ -28,7 +25,7 @@
 </obj:root>'''
 
 class ObjectifyTestCase(HelperTestCase):
-    """Test cases for lxml.elementlib.objectify
+    """Test cases for lxml.objectify
     """
     etree = etree
 

Modified: lxml/branch/lxml-1.3/src/lxml/tests/test_xpathevaluator.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/test_xpathevaluator.py	(original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/test_xpathevaluator.py	Tue Jun 12 18:06:23 2007
@@ -104,6 +104,10 @@
         self.assertEquals(
             [root[0]],
             root.xpath('//baz:b', {'baz': 'uri:a'}))
+
+    def test_xpath_ns_none(self):
+        tree = self.parse('<a xmlns="uri:a"><b></b></a>')
+        root = tree.getroot()
         self.assertRaises(
             TypeError,
             root.xpath, '//b', {None: 'uri:a'})

Modified: lxml/branch/lxml-1.3/src/lxml/tree.pxd
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tree.pxd	(original)
+++ lxml/branch/lxml-1.3/src/lxml/tree.pxd	Tue Jun 12 18:06:23 2007
@@ -97,6 +97,7 @@
         xmlAttr* properties
         xmlNs* ns
         xmlNs* nsDef
+        unsigned short line
 
     ctypedef struct xmlDtd:
         char* ExternalID
@@ -198,6 +199,7 @@
     cdef xmlNs* xmlSearchNs(xmlDoc* doc, xmlNode* node, char* prefix)
     cdef xmlNs* xmlSearchNsByHref(xmlDoc* doc, xmlNode* node, char* href)
     cdef int xmlIsBlankNode(xmlNode* node)
+    cdef long xmlGetLineNo(xmlNode* node)
     cdef void xmlElemDump(FILE* f, xmlDoc* doc, xmlNode* cur)
     cdef void xmlNodeDumpOutput(xmlOutputBuffer* buf,
                                 xmlDoc* doc, xmlNode* cur, int level,


More information about the lxml-checkins mailing list