1.4. Script sections and events

The script of an element, attribute or text node may contain several sections. So far we described the quantifier of an item and the method used to validate a text value of attribute or text node. This pair is called validation section(note that in the script of an element the specification of validation method is not permitted). The other sections are introduced by keywords which indicates the situation or event when in the code of a section will be invoked. See following table:
match          invoked before the item is processed. The invoked code must return a Boolean value.
               The item is accepted for further processing only if the value is "true".
default        invoked if the attribute or the text node is missing. The invoked code must return
               the value convertible to the String.
init           invoked when processing of the item started (before other actions).
onElementStart invoked when all attributes were processed, but before the processing of child nodes
               of the processed element.
finally        invoked at the end of processing of the element.
onTrue         invoked if the validation method of an attribute or text node didn't recognize an error.
onFalse        invoked if the validation method of an attribute or text node recognized an error.
onAbsence      invoked if the item is missing (never invoked if "default" is specified).
create         invoked only in the construction mode (will be described later).
options        set parameters used when an item is processed.
<Book xd:script="init outln('Book processing started'); finally outln('finished');"
      isbn="int(10000000, 999999999); onTrue outln('isbn is OK');"
      published="optional gYear(); onFalse outln('date error'); onAbsence outln('date missing');" > 
  <Author xd:script="occurs *"> <xd:text> string(); </xd:text> </Author>
  <Title> <xd:text> string(); </xd:text> </Title>

Prev  Content   Next