XMLBeans
  1. XMLBeans
  2. XMLBEANS-412

CLONE -Pattern facet regex requires dash - to be escaped

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Version 2, Version 2.1, Version 2.2, Version 2.2.1, Version 2.3, Version 2.3.1
    • Fix Version/s: Version 2
    • Component/s: Validator
    • Labels:
      None
    • Environment:
      Win 2000, JDK1.5

      Description

      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 '-'.

      A dash at the end or at the beginning of a character range does not have to be escaped (see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#nt-charRange "The - character is a valid character range only at the beginning or end of a - positive character group- .")

      The regular expression in the email example is a valid xsd regexp and should be accepted by the XmlBeans validator.

      1. xmlbeans-412.patch
        2 kB
        Jerry Sy
      2. ParserForXMLSchema.java
        22 kB
        Jerry Sy

        Issue Links

          Activity

          Jerry Sy made changes -
          Attachment xmlbeans-412.patch [ 12521586 ]
          Attachment ParserForXMLSchema.java [ 12521587 ]
          Radosław Ceszkiel made changes -
          Description 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 '\-'.


          A dash at the end or at the beginning of a character range does not have to be escaped (see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#nt-charRange, "The - character is a valid character range only at the beginning or end of a - positive character group- .")

          The regular expression in the email example is a valid xsd regexp and should be accepted by the XmlBeans validator.







          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 '\-'.


          A dash at the end or at the beginning of a character range does not have to be escaped (see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#nt-charRange "The - character is a valid character range only at the beginning or end of a - positive character group- .")

          The regular expression in the email example is a valid xsd regexp and should be accepted by the XmlBeans validator.







          Radosław Ceszkiel made changes -
          Description 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.








          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 '\-'.


          A dash at the end or at the beginning of a character range does not have to be escaped (see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#nt-charRange, "The - character is a valid character range only at the beginning or end of a - positive character group- .")

          The regular expression in the email example is a valid xsd regexp and should be accepted by the XmlBeans validator.







          Radosław Ceszkiel made changes -
          Affects Version/s Version 2.1 [ 12310100 ]
          Affects Version/s Version 2.2 [ 12311952 ]
          Affects Version/s Version 2.2.1 [ 12312010 ]
          Affects Version/s  Version 2.3 [ 12312466 ]
          Affects Version/s  Version 2.3.1 [ 12312467 ]
          Radosław Ceszkiel made changes -
          Field Original Value New Value
          Link This issue is a clone of XMLBEANS-224 [ XMLBEANS-224 ]
          Radosław Ceszkiel created issue -

            People

            • Assignee:
              Unassigned
              Reporter:
              Radosław Ceszkiel
            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development