[Lxml-checkins] r51100 - in lxml/trunk: . doc

scoder at codespeak.net scoder at codespeak.net
Mon Jan 28 15:44:38 CET 2008


Author: scoder
Date: Mon Jan 28 15:44:37 2008
New Revision: 51100

Modified:
   lxml/trunk/   (props changed)
   lxml/trunk/doc/objectify.txt
   lxml/trunk/doc/validation.txt
Log:
 r3357 at delle:  sbehnel | 2008-01-28 15:44:16 +0100
 doc cleanup


Modified: lxml/trunk/doc/objectify.txt
==============================================================================
--- lxml/trunk/doc/objectify.txt	(original)
+++ lxml/trunk/doc/objectify.txt	Mon Jan 28 15:44:37 2008
@@ -362,18 +362,18 @@
 Asserting a Schema
 ==================
 
-When dealing with XML documents from different sources, it can often
-be interesting to assure that they follow a common schema.  In
-lxml.objectify, this directly translates to enforcing a specific
-object tree, i.e. expected object attributes are ensured to be there
-and to have the expected type.  This can easily be achieved through
-XML Schema validation at parse time.  Also see the `documentation on
-validation`_ on this topic.
+When dealing with XML documents from different sources, you will often
+require them to follow a common schema.  In lxml.objectify, this
+directly translates to enforcing a specific object tree, i.e. expected
+object attributes are ensured to be there and to have the expected
+type.  This can easily be achieved through XML Schema validation at
+parse time.  Also see the `documentation on validation`_ on this
+topic.
 
 .. _`documentation on validation`: validation.html
 
 First of all, we need a parser that knows our schema, so let's say we
-parse the schema from a file (or filename or file-like object)::
+parse the schema from a file-like object (or file or filename)::
 
     >>> from StringIO import StringIO
     >>> f = StringIO('''\
@@ -388,12 +388,14 @@
     ... ''')
     >>> schema = etree.XMLSchema(file=f)
 
-When creating the validating parser, we must make sure it returns
-objectify trees.  This is best done with the ``makeparser()``
+When creating the validating parser, we must make sure it `returns
+objectify trees`_.  This is best done with the ``makeparser()``
 function::
 
     >>> parser = objectify.makeparser(schema = schema)
 
+.. _`returns objectify trees`: #advance-element-class-lookup
+
 Now we can use it to parse a valid document::
 
     >>> xml = "<a><b>test</b></a>"
@@ -409,8 +411,8 @@
     Traceback (most recent call last):
     XMLSyntaxError: Element 'c': This element is not expected.
 
-Note that the same works for parse-time DTD validation, except that it
-does not support any data types by design.
+Note that the same works for parse-time DTD validation, except that
+DTDs do not support any data types by design.
 
 
 ObjectPath

Modified: lxml/trunk/doc/validation.txt
==============================================================================
--- lxml/trunk/doc/validation.txt	(original)
+++ lxml/trunk/doc/validation.txt	Mon Jan 28 15:44:37 2008
@@ -75,6 +75,10 @@
   Traceback (most recent call last):
   XMLSyntaxError: Element 'a': 'not int' is not a valid value of the atomic type 'xs:integer'.
 
+If you want the parser to succeed regardless of the outcome of the
+validation, you should use a non validating parser and run the
+validation separately after parsing the document.
+
 
 DTD
 ---


More information about the lxml-checkins mailing list