RE: regular expressions in xml schema

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 UTC