[haXe] xml.Check incosistencies

Nicolas Cannasse ncannasse at motion-twin.com
Wed Apr 11 10:04:47 CEST 2007


> Hi Nicolas, long time no bug ya, hehe
> I have a pair of questions about xml.Check.
[...]
> Why is this? I was expecting to get:
> 
>  In request.service.info.id<whatever>: invalid data format for <whatever
> i put>
[...]
> I need a consistent behavior because this will validate xml sent by our
> clients,
> and I catch the error and return it nicely formated in xml so they can
> know what
> the error was. This messages will only confuse them. I'm doing something
> wrong?

Yes, this is the current implementation of RChoice. If no choice is
matched, the error is always reported with comparison to the first rule
in the choice. This is because it would be difficult to find the rule
that is the most close to the xml data available. You can however
suggest an implementation for that if you feel like tackling the problem ;)

>From std/haxe/xml/Check.hx :

case RChoice(choices):
	if( choices.length == 0 )
		throw "No choice possible";
	for( c in choices )
		if( check(x,c) == CMatch )
			return CMatch;
	return check(x,choices[0]);


Nicolas



More information about the Haxe mailing list