<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><style>p {margin:0px;padding:0px;} blockquote { border: 0px; margin-top: 0px; margin-bottom: 0px; }</style></head><body style="">
<p><font color="#000000" face="Verdana" size="2">Hi,</font></p><p> </p><font color="#000000" face="Verdana" size="2"><blockquote type="cite">I should have written I'd like to define a complex type, as stated in<br>the end of the following chapter.<br><br><a href="http://codespeak.net/lxml/objectify.html#how-data-types-are-matched">http://codespeak.net/lxml/objectify.html#how-data-types-are-matched</a><br> </blockquote></font><p> </p><p>Hm, it is not really a complex type (in XML Schema terms), but rather a custom </p><p>simple data type. </p><p><font color="#000000" face="Verdana" size="2"> </font><font color="#000000" face="Verdana" size="2"><blockquote type="cite">In my case, writing a type checker would be impossible - or very<br>difficult. I understand I can also use a py:pytype attribute, but I'd<br>like to try the xsi namespace if possible.<br></blockquote></font></p><p> </p><p>Have you tried registering your custom type as an xmlSchemaType, as in:</p><p> </p><p>>>> my_strange_type.xmlSchemaTypes = ("myns:mytypename",)</p><p> </p><p>Not sure if this will work though, as lxml.objectify currently expects xsi:type </p><p>information to contain xsd:<typename>hints, i.e. the xsi:type infos must come</p><p>from the XML Schema namespace. At least the DataElement() factory will choke:</p><p> </p><p>>>> objectify.DataElement(3, _xsi="foo:bar")<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in ?<br> File "lxml.objectify.pyx", line 1708, in lxml.objectify.DataElement<br>ValueError: XSD types require the XSD namespace<br>>>> <br></p><p> </p><p> </p><p>Maybe you can achieve what you need by taking a look at the "Using custom element</p><p>classes in lxml" section? </p><p><br>Good luck,</p><p>H. </p><p> </p><p></p><p></p><p></p><p></p><p></p><h1></h1><p></p><h1></h1><p></p><h1></h1><div class="signature"><br /><br /><br />-- <br />GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.<br />Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail</div></body></html>