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

SchemaFactory should issue an error to unresolved import/include

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • xml

      Suppose I have a schema that consists of multiple files (say foo.xsd that includes bar.xsd.),
      but I forgot to package bar.xsd and only have foo.xsd

      When I parse foo.xsd by SchemaFactory.newSchema(new File("foo.xsd")), the JAXP RI does not report
      any error when <xsd:include href="bar.xsd"/> fails due to the missing bar.xsd.

      Instead, ultimately it reports an error for undefined components, like this:

        org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'j2ee:descriptionGroup' to a(n) 'group' component.

      For users, especially for those who are not very familiar with XML Schema, this is a real productivity killer.If the error message were to say something like "unable to find bar.xsd", then they would be able to fix it relatively quickly. But the above error message doesn't point them to the right direction. If there are many schema files, then you'd also have to figure out which reference is wrong, which is quite non-trivial.

      The other mode of failure includes:

        1) bar.xsd is there but it has a typo that causes well-formedness error
        2) bar.xsd is there but it contains a DOCTYPE that didn't resolve

      Figuring out the proper cause without any helpful error message, as you'd imagine, is quite frustrating.


      One background fact to be considered is that the XML Schema spec does allow tools to handle it in this way (it also allows it to report errors, too), and based on this, the Xerces team in the past claimed that this is not a bug but a feature.

      I think this is a "feature" that does more harm than good, and completely goes against EoD principle. Now that the JAXP team owns the source code, I hope we make the change in the behavior and report an error on this.

      For those few that wishes the original behavior of ignoring those errors could install their ErrorHandler on SchemaFactory and ignore errors.

            Unassigned Unassigned
            kkawagucsunw Kohsuke Kawaguchi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: