Commit 7d455237 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[xsd gen] Enhance xsd_serialize function

Clearer handling of entities, drop case of date/datetime (we may only have bool
or string final values).
parent a6f4370d6f6e
......@@ -16,7 +16,6 @@
"""cubicweb-seda entity's classes"""
from collections import defaultdict
from datetime import date, datetime
from lxml import etree
from pyxst.xml_struct import graph_nodes
......@@ -353,21 +352,17 @@ def xsd_serialize(value):
"""Return XSD value as a string depending on the type of the given `value`."""
if value is None:
return None
if hasattr(value, 'labels'):
# value is a Concept
if hasattr(value, 'eid'):
if value.cw_etype == 'Concept':
return value.labels['en']
if hasattr(value, 'id'):
# value is something in the profile which has a id
# value is something in the profile which has a id (e.g. archive unit, data object)
if hasattr(value, 'eid'):
return None # intermediary entity
if isinstance(value, bool):
return 'true' if value else 'false'
if isinstance(value, (date, datetime)):
return value.isoformat() + 'Z'
# if isinstance(value, Binary):
# return b64encode(value.getvalue)
return unicode(value) # XXX
assert isinstance(value, basestring), repr(value)
return unicode(value)
def xsd_element_cardinality(occ, card_entity):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment