<!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>&nbsp;</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>&nbsp;</blockquote></font><p>&nbsp;</p><p>Hm, it is not really a complex type (in XML Schema terms), but rather a custom </p><p>simple data type.&nbsp;</p><p><font color="#000000" face="Verdana" size="2">&nbsp;</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>&nbsp;</p><p>Have you tried registering your custom type as an xmlSchemaType, as in:</p><p>&nbsp;</p><p>&gt;&gt;&gt; my_strange_type.xmlSchemaTypes = ("myns:mytypename",)</p><p>&nbsp;</p><p>Not sure if this will work though, as lxml.objectify currently expects xsi:type </p><p>information to contain xsd:&lt;typename&gt;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>&nbsp;</p><p>&gt;&gt;&gt; objectify.DataElement(3, _xsi="foo:bar")<br>Traceback (most recent call last):<br>&nbsp; File "&lt;stdin&gt;", line 1, in ?<br>&nbsp; File "lxml.objectify.pyx", line 1708, in lxml.objectify.DataElement<br>ValueError: XSD types require the XSD namespace<br>&gt;&gt;&gt; <br></p><p>&nbsp;</p><p>&nbsp;</p><p>Maybe you can achieve what you need by taking a look at the "Using custom element</p><p>classes in lxml" section?&nbsp;</p><p><br>Good luck,</p><p>H.&nbsp;</p><p>&nbsp;</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>