The rule
just states that the attribute must exist and makes no assumptions about its content. To apply a
validation on the attribute value, see the next section about filtering values.
// valid
< person name=???John Doe??? / >
// valid, too
< person name=?????? / >
Part III: Extending the Possibilities
462
When the attribute rule also specifies a default value, the content of the original node can be modified
during validation. For the following rule the node must have an attribute with the name sex ; if the
attribute is not present, a default one is automatically created with value m .
var schema = RNode(???person???, [Att(???name???), Att(???sex???, ???m???)]);
Therefore, the first node person from the previous example is valid for the above rule but is changed
as follows:
< person name=???John Doe??? sex=???m???/ >
Filtering Values
Filter rules can be applied to nodes of type CData or PCData or to attribute values. The Filter enum
has four very intuitive constructors. The first FInt checks for string values that can be converted to
integer values.
Pages:
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858