Please ignore my previous message; I solved my own problem by finding an XML schema for what I need to do.<br><br>Sorry for the noise.<br><br><div class="gmail_quote">On Tue, Jun 30, 2009 at 3:04 PM, Elliott Slaughter <span dir="ltr"><<a href="mailto:elliottslaughter@gmail.com">elliottslaughter@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>I'm trying to get the elements in a DTD. Since these internals are not exported in the Python interface of lxml.etree, I am trying to write a Cython extension to do so, as previously suggested on this mailing list (see link below).<br clear="all">
<br><a href="http://codespeak.net/pipermail/lxml-dev/2009-January/004298.html" target="_blank">http://codespeak.net/pipermail/lxml-dev/2009-January/004298.html</a><br>
<br>To quote the message, "all you'd really need is the internal _c_dtd field of the DTD class, which you could cimport". I'm wondering exactly how I am supposed to do that (my attempts so far are described below). It would also be nice to know if the last attempt to do so was successful or not.<br>
<br>Thanks. Any help would be appreciated.<br><br><br><br>Here is what I've tried so far (on Python 2.5.4, Cython 0.11.2, Windows):<br><br>The DTD class is not declared in etreepublic.pxd, so I can't just "cimport etreepublic". The actual DTD class definition is in dtd.pxi, as stated in the message. But I can't just "include 'dtd.pxi' " because it inherits from the _Validator class in lxml.etree.pyx . And I can't "cimport lxml.etree" because there is no file lxml.etree.pxd.<br>
<br>I tried writing a lxml.etree.pxd file to circumvent these barriers (which was thoroughly confusing because _Validator contains an _ErrorLog which made me search through several other files...), but even when I got the entire thing to compile, it failed to load in Python:<br>
<br>>>> import mydtd<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br> File "lxml.etree.pxd", line 3, in mydtd (mydtd.c:513)<br> cdef class _LogEntry:<br>
ValueError: lxml.etree._LogEntry does not appear to be the correct type object<br><br>I have attached my lxml.etree.pxd in case I made any mistakes, in the event that this method can be made to work.<br><font color="#888888"><br>
-- <br>
Elliott Slaughter<br><br>"Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Elliott Slaughter<br><br>"Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay<br>