[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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>
xmlspy regular expressions

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

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.