From: <ps...@us...> - 2008-12-11 04:20:28
|
Revision: 1475 http://pywebsvcs.svn.sourceforge.net/pywebsvcs/?rev=1475&view=rev Author: psha Date: 2008-12-11 04:20:26 +0000 (Thu, 11 Dec 2008) Log Message: ----------- Support parsing TC.XML with maxOccurs > 1 Backward compatible behaviour (e.g returning None or Element) when maxOccurs = 1. Otherwise list of elements is returned (may be empty if minOccurs = 0) Modified Paths: -------------- trunk/zsi/ZSI/TC.py Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2008-12-10 08:08:21 UTC (rev 1474) +++ trunk/zsi/ZSI/TC.py 2008-12-11 04:20:26 UTC (rev 1475) @@ -1247,11 +1247,17 @@ #raise EvaluateException('Embedded XML has unknown encodingStyle', # ps.Backtrace(elt) pass - if len(c) != 1: - raise EvaluateException('Embedded XML has more than one child', + if len(c) < self.minOccurs: + raise EvaluateException('Not enough XML children %d (minOccurs = %d)' % (len(c), self.minOccurs), ps.Backtrace(elt)) - if self.copyit: return c[0].cloneNode(1) - return c[0] + if self.maxOccurs != UNBOUNDED and len(c) > self.maxOccurs: + raise EvaluateException('Too many XML children %d (maxOccurs = %d)' % (len(c), self.maxOccurs), + ps.Backtrace(elt)) + if self.copyit: + c = map(lambda n: n.cloneNode(1), c) + if self.maxOccurs == 1: + return c[0] + return c def serialize(self, elt, sw, pyobj, name=None, unsuppressedPrefixes=[], **kw): objid = _get_idstr(pyobj) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |