W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2002

Re: HELP Required in XML validation against XSD schema for Email and Phone number

From: <noah_mendelsohn@us.ibm.com>
Date: Mon, 16 Dec 2002 14:50:05 -0500
To: sankar s <sankarsb@yahoo.com>
Cc: xmlschema-dev@w3.org, xmlschema-dev-request@w3.org
Message-ID: <OF7663AE88.7C1DC369-ON85256C91.006D07D8@lotus.com>

Sankar writes:

> I need some help in implementing the some validation in
> XML schema (xsd files)
> 
> 1. Phone number must be string of 10 chars and first
> three chars must be number
> 
> 2. Emai should have "@" and "." in it.(Basic Email validation)
Use the pattern facet for both of these. [1,2]

> 3. Date should be in "yyyy-mon-dd" format
If you really mean a three character month such as "Jan" 
for the English word January, that's not supported by
the schema date type.  Quoting from the recommendation [3]:

"The lexical representation for date is the reduced
(right truncated) lexical representation for dateTime:
CCYY-MM-DD. No left truncation is allowed. An optional
following time zone qualifier is allowed as for
dateTime. To accommodate year values outside the range
from 0001 to 9999, additional digits can be added to
the left of this representation and a preceding "-"
sign is allowed.

For example, to indicate May the 31st, 1999, one would
write: 1999-05-31. See also ISO 8601 Date and Time
Formats (žD)."

You can use the pattern facet to restrict this further,
but not to introduce any forms that are not legal as
documented above.

Hope this helps.

Noah

[1] http://www.w3.org/TR/xmlschema-2/#rf-pattern
[2] http://www.w3.org/TR/xmlschema-2/#dt-regex
[3] http://www.w3.org/TR/xmlschema-2/#date

------------------------------------------------------------------
Noah Mendelsohn                              Voice: 1-617-693-4036
IBM Corporation                                Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------
Received on Monday, 16 December 2002 14:53:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:35 GMT