summaryrefslogtreecommitdiff
path: root/pyxb/binding
diff options
context:
space:
mode:
authorPeter A. Bigot <pabigot@users.sourceforge.net>2010-05-28 18:40:03 -0500
committerPeter A. Bigot <pabigot@users.sourceforge.net>2010-05-28 18:40:03 -0500
commit863fda964a9bdbf43e8ea9b10cb9e19d3623099b (patch)
tree0d6c0c5f48fb294f1951bc5c75c1a39a780583ec /pyxb/binding
parent1ff788f23c44dee28207f0da0174d6a9717a51b3 (diff)
Implement wildcard matching and validation
Diffstat (limited to 'pyxb/binding')
-rw-r--r--pyxb/binding/content.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/pyxb/binding/content.py b/pyxb/binding/content.py
index 4b43ba2..3c8cfca 100644
--- a/pyxb/binding/content.py
+++ b/pyxb/binding/content.py
@@ -761,12 +761,27 @@ class Wildcard (ContentState_mixin):
"""
return True
+ def accepts (self, state_stack, ctd, value, element_use):
+ value_desc = 'value of type %s' % (type(value),)
+ if not self.matches(ctd, value):
+ raise pyxb.UnexpectedContentError(value)
+ if not isinstance(value, basis._TypeBinding_mixin):
+ print 'NOTE: Created unbound wildcard element from %s' % (value_desc,)
+ assert isinstance(ctd.wildcardElements(), list), 'Uninitialized wildcard list in %s' % (ctd._ExpandedName,)
+ ctd._appendWildcardElement(value)
+ return True
+
def _validate (self, symbol_set, output_sequence):
# @todo check node against namespace constraint and process contents
#print 'WARNING: Accepting node as wildcard match without validating.'
- if 0 == len(symbol_set):
+ wc_values = symbol_set.get(None)
+ if wc_values is None:
return False
- raise pyxb.IncompleteImplementationError('Wildcard validation')
+ used = wc_values.pop(0)
+ output_sequence.append( (None, used) )
+ if 0 == len(wc_values):
+ del symbol_set[None]
+ return True
## Local Variables:
## fill-column:78