[lxml-dev] About objectify
jholg at gmx.de
jholg at gmx.de
Tue Jan 22 17:31:33 CET 2008
Hi,
> I should have written I'd like to define a complex type, as stated in
> the end of the following chapter.
>
> http://codespeak.net/lxml/objectify.html#how-data-types-are-matched
>
Hm, it is not really a complex type (in XML Schema terms), but rather a
custom
simple data type.
> In my case, writing a type checker would be impossible - or very
> difficult. I understand I can also use a py:pytype attribute, but I'd
> like to try the xsi namespace if possible.
>
Have you tried registering your custom type as an xmlSchemaType, as in:
>>> my_strange_type.xmlSchemaTypes = ("myns:mytypename",)
Not sure if this will work though, as lxml.objectify currently expects
xsi:type
information to contain xsd:<typename>hints, i.e. the xsi:type infos must
come
from the XML Schema namespace. At least the DataElement() factory will
choke:
>>> objectify.DataElement(3, _xsi="foo:bar")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "lxml.objectify.pyx", line 1708, in lxml.objectify.DataElement
ValueError: XSD types require the XSD namespace
>>>
Maybe you can achieve what you need by taking a look at the "Using
custom element
classes in lxml" section?
Good luck,
H.
--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/lxml-dev/attachments/20080122/982a9557/attachment.htm
More information about the lxml-dev
mailing list