W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2005

RE: regular expressions in xml schema

From: Michael Kay <mike@saxonica.com>
Date: Fri, 11 Mar 2005 15:09:46 -0000
To: "'Bryan Rasmussen'" <brs@itst.dk>, <xmlschema-dev@w3.org>
Message-ID: <E1D9lm3-0008Ao-UP@frink.w3.org>

Saxon also reports name@address.com as invalid. The reason is that in XML
Schema, regular expressions are implicitly anchored, and the characters "^"
and "$" therefore represent themselves.

It would probably have been a better design choice if these characters had
been disallowed...

Michael Kay
http://www.saxonica.com/  



> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Bryan Rasmussen
> Sent: 11 March 2005 13:14
> To: xmlschema-dev@w3.org
> Subject: regular expressions in xml schema
> 
> 
> Hi, I have the following regular expression for an email address,
> ^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Z
> a-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-z
> A-Z]{2,6}$
> 
> from Gavin Sharp at regexlib
> http://www.regexlib.com/REDetails.aspx?regexp_id=295
> 
> as in 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="http://rep.oio.dk/email"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0"
> xmlns:e="http://rep.oio.dk/email"
> elementFormDefault="qualified">
> 
> 	
> 
> 
> 
> 
> 	<xsd:element name="email" type="e:emailType" />
> 
> <xsd:simpleType name="emailType">
> <xsd:restriction base="xsd:string">
> <xsd:pattern
> value="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Z
> a-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-z
> A-Z]{2,6}$"/>
> </xsd:restriction>
> 	</xsd:simpleType>
> </xsd:schema>
> 
> this works fine when ran in XSV, that is it allows email addresses I
> expected, and disallows non-email strings, however in msxml's 
> schemaCache
> and in XMLSPY professional #3 2004 it won't even accept 
> hello@world.com, now
> I can't say I have a clear understanding on constraints of 
> regex usage in
> xmlschema so what i would like to know is are schemaCache and XMLSPY
> correct? That this regex in xml schema should consider 
> name@address.com type
> addresses as incorrect?
> If so what is wrong with it?
> 
> 
> 
Received on Friday, 11 March 2005 15:09:59 GMT

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