Xerces2-J
  1. Xerces2-J
  2. XERCESJ-1456

Regular expression is incorrectly handled in pattern facet

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.10.0
    • Fix Version/s: 2.11.0
    • Labels:
      None
    • Environment:
      JDK 1.5.0

      Description

      I have the following schema:

      <?xml version="1.0" encoding="UTF-8"?>
      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="test" type="Test"/>
      <xsd:simpleType name="Test">
      <xsd:restriction base="xsd:string">
      <xsd:pattern value="[0-9]

      {0,3}([0-9]{3})*"/>
      </xsd:restriction>
      </xsd:simpleType>
      </xsd:schema>

      And this xml file:

      <?xml version="1.0" encoding="windows-1252"?>
      <test>1010000</test>

      I try to validate the file with the following test code:

      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      dbf.setNamespaceAware(true);
      DocumentBuilder builder = dbf.newDocumentBuilder();
      Document xsd = builder.parse(Main.class.getResource("/test.xsd").toString());

      SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
      Schema schema = sf.newSchema(new DOMSource(xsd));
      Validator validator = schema.newValidator();

      Document test = builder.parse(Main.class.getResource("/test.xml").toString());
      validator.validate(new DOMSource(test));

      I get an org.xml.sax.SAXParseException: cvc-pattern-valid: Value '1010000' is not facet-valid with respect to pattern '[0-9]{0,3}

      ([0-9]

      {3})*' for type 'Test'.

      In my opinion, the given value should be valid for the given pattern. Even the following code prints "true":

      RegularExpression re = new RegularExpression("[0-9]{0,3}([0-9]{3}

      )*");
      System.out.println(re.matches("1010000"));

        Activity

        Christian Schröder created issue -
        Michael Glavassevich made changes -
        Field Original Value New Value
        Assignee Khaled Noaman [ knoaman@ca.ibm.com ]
        Hide
        Michael Glavassevich added a comment -

        Khaled, I think this may be related to your fix for XERCESJ-589. Please take a look.

        Show
        Michael Glavassevich added a comment - Khaled, I think this may be related to your fix for XERCESJ-589 . Please take a look.
        Hide
        Khaled Noaman added a comment -

        Fix checked in

        Show
        Khaled Noaman added a comment - Fix checked in
        Khaled Noaman made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.11.0 [ 12315151 ]
        Resolution Fixed [ 1 ]
        Mark Thomas made changes -
        Workflow jira [ 12514933 ] Default workflow, editable Closed status [ 12576019 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12576019 ] jira [ 12598926 ]

          People

          • Assignee:
            Khaled Noaman
            Reporter:
            Christian Schröder
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development