cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard In Public" <edificat...@blueyonder.co.uk>
Subject XmlForm Validation Problem: Where Am I Going Wrong?
Date Fri, 07 Mar 2003 00:48:03 GMT
Hi

I think I'm pretty close to having things up and running with XMLForms.  I'm
having some problems with the validation though.  I'm trying to achieve
conditional validation:  I have two password fields and the second should
only be effected if a password has been entered in the first.  I don't want
to do this in the '/' content as I want any violations to be associated with
the second field.  I've tried everything that I can think of.  Here is one
of the attempts. Everything works except the validation of the second
password field.  No violations are reported when I fill in only the first
field.  Where am I going wrong?

My my dead lines are turning pale blue and gasping for breath.  Please
please help me!

Richard

------------------------ Validation Schema(tron) ---------------------
<?xml version="1.0" ?>
<schema ns="http://xml.apache.cocoon/xmlform"
xmlns="http://www.ascc.net/xml/schematron">
<title>Account Registration Schema</title>
<phase id="registration">
<p>For user identity information.</p>
<active pattern="reg"/>
</phase>
<pattern name="User Info Validation Pattern" id="reg">
<rule context="/emailAddress">
<assert test="contains( string(.),'@')">
Email format is invalid.
</assert>
</rule>
<rule context="/password">
<assert test="string-length(.) &gt; 7">
Password should be at least 8 characters.
</assert>
<assert test="string-length(.) &lt; 20">
Password should be less than 20 characters.
</assert>
</rule>
<rule context="/repeatedPassword">
<report test="(string-length(/password) &gt; 0) and (string-length(.) = 0)">
Please confirm your password.
</report>
</rule>
</pattern>
</schema>
----------------------------------------
XMLForm --------------------------------
<?xml version="1.0" ?>
<xf:form xmlns:xf="http://xml.apache.org/cocoon/xmlform/2002"
id="form-feedback" view="registration" action="new-account.xml"
xmlns:site="http://designedandmanaged.net/cocoon/site/1.0">
<error>
<xf:violations class="error"/>
</error>
<xf:textbox ref="/emailAddress">
<xf:caption>Email Address</xf:caption>
<xf:violations class="error" />
</xf:textbox>
<xf:password ref="/password">
<xf:caption>Password</xf:caption>
<xf:violations class="error" />
</xf:password>
<xf:password ref="/repeatedPassword">
<xf:caption>Password (Confirm)</xf:caption>
<xf:violations class="error" />
</xf:password>
<xf:textbox ref="/firstName">
<xf:caption>First Name</xf:caption>
<xf:violations class="error" />
</xf:textbox>
<xf:textbox ref="/lastName">
<xf:caption>Last Name</xf:caption>
<xf:violations class="error" />
</xf:textbox>
<xf:textbox ref="/phoneNumber">
<xf:caption>Phone Number</xf:caption>
<xf:violations class="error" />
</xf:textbox>
<xf:textbox ref="/address1">
<xf:caption>Line 1</xf:caption>
<xf:violations class="error" />
</xf:textbox>
<xf:textbox ref="/address2">
<xf:caption>Line 2</xf:caption>
<xf:violations class="error" />
</xf:textbox>
<xf:textbox ref="/address3">
<xf:caption>Line 3</xf:caption>
<xf:violations class="error" />
</xf:textbox>
<xf:textbox ref="/city">
<xf:caption>City</xf:caption>
<xf:violations class="error" />
</xf:textbox>
<xf:textbox ref="/postCode">
<xf:caption>Post Code</xf:caption>
<xf:violations class="error" />
</xf:textbox>
<xf:textbox ref="/countryID">
<xf:caption>Country</xf:caption>
<xf:violations class="error" />
</xf:textbox>
<xf:submit id="next" class="button">
<xf:caption>Create My Account</xf:caption>
<xf:hint>Go to next page</xf:hint>
</xf:submit>
</xf:form>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Mime
View raw message