<bigwig> service: format


service {
  format Digit = range('0', '9');
  
  format Number = plus ( Digit );
  
  format Alpha = union(range('a', 'z'), range('A', 'Z'));
  
  format Word = concat(Alpha, star(union(Digit, Alpha)));
  
  format Name = concat(Word, star(concat(" ", Word)));
  
  format Email = concat(Word, "@", Word, star(concat(".", Word)));
  
  html InputInfo = <html>
    <table>
      <tr>
        <td>Enter your name:</td>
        <td><input type=text name="your_name"></td>
      </tr>
      <tr>
        <td>Enter your age:</td>
        <td><input type=text name="your_age"></td>
      </tr>
      <tr>
        <td>Enter your email:</td>
        <td><input type=text name="your_email"></td>
      </tr>
    </table>
    <p>
    The three fields are submitted to client-side input validation. This ensures that
    the data entered complies with certain regular expression formats defined
    in the <tt><font color="#ff0000">&lt;</font>bigwig<font color="#ff0000">&gt;</font></tt>
    source code for this service.
    <format field="your_name" warning="A name consists of more than one word each with capital first letter." error="The name is not valid!">
      <bigwig-regexp idref="Name"/></format>
    <format field="your_age" error="The age is not valid!"><bigwig-regexp idref="Number"/></format>
    <format field="your_email" warning="The email address is not complete ..." error="The email address is not valid!">
      <bigwig-regexp idref="Email"/></format>
  </html>;
  html OutputInfo = <html>
    Your name is <b><[your_name]></b>, you are <b><[your_age]></b> years old, 
    and your email address is <b><[your_email]></b>.
  </html>;
  
  session Enter() {
    int age;
    string name, email;
    
    show InputInfo receive [name=your_name, age=your_age, email=your_email];
    exit OutputInfo <[your_name=name, your_age=age, your_email=email];
  }
}