[haXe] Bugfix proposal: RMulti case in haxe.xml.Check.hx
Stefan Thurnherr
stefan.thurnherr at gmail.com
Tue Apr 24 14:09:18 CEST 2007
Hi Nicolas,
The RMulti rule did not work properly for me. After some digging into
haxe.xml.Check.hx I found that the following bugfixes ensure proper
validation of an XML against a rule that includes an RMulti rule.
haxe.xml.Check::checkList::case RMulti:
<code>
case RMulti(r,one):
var oneFound:Bool = false;
for( x in it ) {
if( isBlank(x) )
continue;
oneFound = true;
var m = checkList([x].iterator(),r);
if( m != CMatch )
return m;
}
if ( one && !oneFound )
return CMissing(r);
return CMatch;
</code>
The problem with the previous version was that the case RMulti
stumbled across the PCData element that every XML element has. That
element was submitted to checkList() and was then found as being
empty. So the first fix was to insert the isBlank() check.
The second bugfix was to move the check for the ?atLeastOne flag after
the for loop and checking whether at least one non-blank element was
returned by the iterator (instead of it.hasNext() which also returns
true if the iterator returns a blank element).
HTH,
stefan.
More information about the Haxe
mailing list