Prev | Current Page 839 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The first is quite easy to write and to interpret but it is quite limited in
expressiveness; the latter is far more advanced but more complex, too. haXe tries to mediate complexity
and richness with a native solution known under the name of Check . The Check class only provides two
public static methods: checkNode() and checkDocument() . The first is used to validate the correctness
of a generic node and the second is specific for nodes of type Document . The functions do not return
anything but throw an error if any validation rule fails; both accept an Xml instance as a first argument
and a rule definition as a second. All the magic of the validation is in the defined rules.
Because the class relies heavily on the EReg class, Check is not available on Flash 6 to 8.
The following example shows how to check an XML document. The validation rule applied states that
the document must have one child with the name root, no attributes, and no children.
import haxe.xml.Check;
class Main
{
public static function main()
{
var xml = ??? < root > < /root > ???;
var doc = Xml.


Pages:
827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851