[Lxml-checkins] r50932 - in lxml/trunk: . doc
scoder at codespeak.net
scoder at codespeak.net
Wed Jan 23 17:10:10 CET 2008
Author: scoder
Date: Wed Jan 23 17:10:09 2008
New Revision: 50932
Modified:
lxml/trunk/ (props changed)
lxml/trunk/doc/validation.txt
Log:
r3294 at delle: sbehnel | 2008-01-23 16:52:42 +0100
example how to load a DTD from a catalog
Modified: lxml/trunk/doc/validation.txt
==============================================================================
--- lxml/trunk/doc/validation.txt (original)
+++ lxml/trunk/doc/validation.txt Wed Jan 23 17:10:09 2008
@@ -106,6 +106,17 @@
>>> print dtd.error_log.filter_from_errors()[0]
<string>:1:0:ERROR:VALID:DTD_NOT_EMPTY: Element b was declared EMPTY this one has content
+As an alternative to parsing from a file, you can use the
+``external_id`` keyword argument to parse from a catalog::
+
+ >>> docbook_doctype = "-//OASIS//DTD DocBook XML V4.2//EN"
+ >>> dtd = etree.DTD(external_id = docbook_doctype) # requires catalog support
+
+ >>> root = etree.XML("<article></article>")
+ >>> dtd.assertValid(root) # doctest: +ELLIPSIS
+ Traceback (most recent call last):
+ DocumentInvalid: Element article content does not follow the DTD ...
+
RelaxNG
-------
More information about the lxml-checkins
mailing list