Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6246667

XML Schema regular expression handling not per W3C

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • 5.0
    • 5.0
    • xml
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Professional

      A DESCRIPTION OF THE PROBLEM :
      Using SchemaFactory.addSchema with an XML Schema that has existed for years using other validation techniques returns the following error:

      Caused by: org.sifinfo.sif1x.SIFException: org.xml.sax.SAXParseException: InvalidRegex: Pattern value 'UTC[-+]([0-1][0-9]|[2][0-3]):[0-5][0-9]' is not a valid regular expression. The reported error was: ''-' is an invalid character range. Write '\-'.'.
      at org.sifinfo.sif1x.SIF_1_x.addXMLSchema(SIF_1_x.java:579)
      at org.sifinfo.sif1x.compliance.TestHarness.createAgentTestSession(TestHarness.java:31)
      ... 36 more

      It was [+-]. Neither works. Both are valid per W3C and shouldn't require escaping:

      F.1 Character Classes

      ...

      A single XML character is a ·character range· that identifies the set of characters containing only itself. All XML characters are valid character ranges, except as follows:

      The [, ], - and \ characters are not valid character ranges;
      The ^ character is only valid at the beginning of a ·positive character group· if it is part of a ·negative character group·
      The - character is a valid character range only at the beginning or end of a ·positive character group·.

      ...

      Per the last point here, both [+-] and [-+] are valid character ranges.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create an XML Schema with a similar regular expression. Load it using SchemaFactory.addSchema. Similar exception will be thrown.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      XML Schema to be parsed as with previous Java versions (that did not have SchemaFactory.addSchema).
      ACTUAL -
      See above.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      See above.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      See above.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Will escape - per exception, but it is not necessary per W3C spec.
      ###@###.### 2005-03-28 13:50:23 GMT

            joehw Joe Wang
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: