<?xml-stylesheet href="../xsltforms/xsltforms.xsl" type="text/xsl"?>
<?xsltforms-options debug="no"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:h="http://www.w3.org/1999/xhtml" 
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:math="http://exslt.org/math"
>
<head>
    <title>Email addresses</title>
    <style type="text/css">
	body {font-family: sans-serif; margin: 2em; max-width: 50em;}
	.xforms-label {display: inline-block; font-weight: bold; width: 15em; text-align: right; padding-right: 1ex;}
	.xforms-group > .xforms-label {color: white; background-color: blue}
        .xforms-input {display: block}
	input.xforms-value {width: 20em}
    </style>
    <model xmlns="http://www.w3.org/2002/xforms">
        <schema xmlns="http://www.w3.org/2001/XMLSchema">
	    <simpleType name="telephone">
	        <restriction base="xsd:string">
	 	   <pattern value="^(\(\ *\+?\ *([0-9]\ *(\-\ *[0-9]\ *)*)+\)\ *([0-9]\ *(\-\ *[0-9]\ *)*)+)|(\+?\ *([0-9]\ *(\-\ *[0-9]\ *)*)+(\(\ *([0-9]\ *(\-\ *[0-9]\ *)*)+\)\ *([0-9]\ *(\-\ *[0-9]\ *)*)+)?)[0-9]$"/>
<!-- was 	   <pattern value="^(\(\ *\+?\ *([0-9]\ *(\-\ *[0-9]\ *)?)+\)\ *([0-9]\ *(\-\ *[0-9]\ *)?)+)|(\+?\ *([0-9]\ *(\-\ *[0-9]\ *)?)+(\(\ *([0-9]\ *(\-\ *[0-9]\ *)?)+\)\ *([0-9]\ *(\-\ *[0-9]\ *)?)+)?)$"/> -->
<!-- was 	   <pattern value="(^[+]?[0-9][0-9-]*[0-9]$)?"/> -->
	        </restriction>
	    </simpleType>
	    <simpleType name="email1">
		<restriction base="xs:string">
 		    <pattern value="([A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)*@([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?)(\.[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?)+"/>
<!-- was "([A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)*@[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)+)?" -->

		</restriction>
	    </simpleType>
	    <simpleType name="email2">
		<restriction base="xs:string">
 		    <pattern value="([A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~&#x00A1;-&#x2FA1F;]+)(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~&#x00A1;-&#x2FA1F;]+)*@([A-Za-z0-9&#xA1;-&#x2FA1F;]([A-Za-z0-9&#xA1;-&#x2FA1F;-]*[A-Za-z0-9&#xA1;-&#x2FA1F;])?)(\.[A-Za-z0-9&#xA1;-&#x2FA1F;]([A-Za-z0-9&#xA1;-&#x2FA1F;-]*[A-Za-z0-9&#xA1;-&#x2FA1F;])?)+"/>
<!-- was "([A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)*@[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)+)?" -->
		</restriction>
	    </simpleType>
        </schema>
	<instance src="email-test-data.xml"/>
	  <bind ref="email" type="email1"/>
	  <bind ref="iemail" type="email2"/>
	  <bind ref="telephone" type="telephone"/>
    </model>
</head>
<body>
  <group xmlns="http://www.w3.org/2002/xforms">
    <group>
      <label>Valid email</label>
        <repeat ref="email[@valid='yes']">
	    <input ref="." incremental="true"><label><output value="@label"/></label><alert>Fix me!</alert></input>
        </repeat>
    </group>
    <group>
      <label>Invalid email</label>
        <repeat ref="email[@valid='no']">
	    <input ref="." incremental="true"><label><output value="@label"/></label><alert>Correctly invalid</alert></input>
        </repeat>
    </group>
    
    <group>
      <label>IETF valid email we don't accept</label>
        <repeat ref="email[@valid='ietf']">
	    <input ref="." incremental="true"><label><output value="@label"/></label><alert>Correctly invalid</alert></input>
        </repeat>
    </group>
    
    <group>
      <label>International email</label>
        <repeat ref="iemail">
	    <input ref="." incremental="true"><label><output value="@label"/></label><alert>Fix me!</alert></input>
        </repeat>
    </group>
    <group>
      <label>Telephone numbers, valid</label>
        <repeat ref="telephone[@valid='yes']">
	    <input ref="." incremental="true"><label><output value="@label"/></label><alert>Fix me!</alert></input>
        </repeat>
    </group>
    <group>
      <label>Telephone numbers, invalid</label>
        <repeat ref="telephone[@valid='no']">
	    <input ref="." incremental="true"><label><output value="@label"/></label><alert>Correctly invalid</alert></input>
        </repeat>
    </group>
</group>
</body>
</html>


