[XML-SIG] docbook 5, lxml and rng
Tim Arnold
Tim.Arnold at sas.com
Fri May 29 16:14:10 CEST 2009
Hi, this is a newbie question I'm sure. I'm trying to validate an example straight out of the docbook 5 documentation (example given on the 'inlineequation' page). As it stands, the file doesn't pass as valid.
The code:
=======================================
from lxml import etree
import os
# RNGDIR = 'path to docbook.rng'
# XMLDIR = 'path to the xml file'
relaxng_doc = etree.parse(os.path.join(RNGDIR,'docbook.rng'))
relaxng = etree.RelaxNG(relaxng_doc)
doc = etree.parse(os.path.join(XMLDIR,'myfile.xml'))
print relaxng.validate(doc)
=======================================
The xml file:
=======================================
<article xmlns="http://docbook.org/ns/docbook">
<title>Example inlineequation</title>
<para>Einstein's theory of relativity includes one of the most
widely recognized formulas in the world:
<inlineequation>
<alt>e=mc^2</alt>
<inlinemediaobject>
<imageobject>
<imagedata fileref="figures/emc2.png"/>
</imageobject>
</inlinemediaobject>
</inlineequation>
</para>
</article>
=======================================
If I remove the inlineequation subtree, it is valid.
Can someone help me understand what I'm missing?
python 2.5.1
lxml-2.1.2-py2.5-freebsd-6.3
thanks,
--Tim Arnold
More information about the XML-SIG
mailing list