The third argument is an optional rule that is applied to the child
elements. If omitted, the node must not have child nodes. The constructor has the following signature:
RNode(name:String, ?attribs:Array < Attrib > , ?childs:Rule);
In the following example, the validation rule checks that a node with the element name book has one
child element with the name author .
var schema = RNode(???book???, RNode(???author???));
// equivalent to
var schema = RNode(???book???, [], RNode(???author???));
Some XML fragments validated using the preceding rule are analyzed in the following code:
// fails because book has no author child node
var xml =??? < book > < /book > ???;
// validation passes
var xml =??? < book > < author/ > < /book > ???;
// fails because book has more than one author child node
var xml =??? < book > < author/ > < author/ > < /book > ???;
RM ulti
The constructor defines a single validation rule, the first argument that is applied to a sequence of
elements. The second argument is a Boolean value that, when true , requires that the sequence must
contain at least one node, when false , that the list can be empty.
Pages:
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853