[ http://issues.apache.org/jira/browse/XMLBEANS-224?page=all ] Peter lynch resolved XMLBEANS-224: ----------------------------------
Fix Version: Version 2 Resolution: Invalid Ok sorry, I understand the error now. The - needs to be escaped not in the range part, but the character part. The correct regex is <xsd:pattern value="([\.a-zA-Z0-9_\-])+@([a-zA-Z0-9_\-])+(([a-zA-Z0-9_\-])*\.([a-zA-Z0-9_\-])+)+"/> > Pattern facet regex requires dash - to be escaped > ------------------------------------------------- > > Key: XMLBEANS-224 > URL: http://issues.apache.org/jira/browse/XMLBEANS-224 > Project: XMLBeans > Type: Bug > Components: Validator > Versions: Version 2 > Environment: Win 2000, JDK1.5 > Reporter: Peter lynch > Fix For: Version 2 > > Given the following xsd that should allow only a valid email address pattern: > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > <xsd:element name="Email" type="EmailType" /> > <xsd:simpleType name="EmailType" > > <xsd:restriction base="xsd:token"> > <xsd:pattern > value="([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(([a-zA-Z0-9_-])*\.([a-zA-Z0-9_-])+)+"/> > </xsd:restriction> > </xsd:simpleType> > </xsd:schema> > Using the following simple xml instance: > <Email>test@test.com</Email> > Running: > validate sample.xsd sample.xml > generates: > Schema invalid: > D:\sample.xsd:7: error: pattern-regex: The regular expression > '([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(([a-zA-Z0-9_-])*\.([a-zA-Z0-9_-])+)+' is > malformed: '-' is an invalid character range. Write '\-'. > Question: Why should I have to escape the dashes?? > Then escaping the dashes, you can actually get the schema to compile. But > then you have a new problem. The regex does validate valid email addresses!! > So two bugs AFAIK - shouldn't need to escape slashes. Something in the regex > is not recognised by xmlbeans regex parser. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]