The only Rule that accepts an attribute constraint is the RNode constructor. The sequence
of the attribute rules is not relevant and all the attribute rules must match for the node to be valid. The
constructor accepts a first mandatory argument that is the name of the attribute that has to be checked.
The second argument is an optional Filter value that acts on the value of the attribute. The third
argument is a default value for the attribute when this is missing. That is, if the attribute rule has a
default value, the attribute becomes optional and when it does not exist in the node, it is automatically
created; if the default value is omitted the attribute is mandatory. The Filter condition is checked only
if the attribute exists at the moment of the validation. The Att constructor has the following signature:
Att( name:String, ?filter:Filter, ?defvalue:String );
The following rule defines that the element to validate must have a name person and an attribute with
name equal to name :
var schema = RNode(???person???, [Att(???name???)]);
The following XML fragment validates correctly, but so does the one with an empty attribute.
Pages:
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857