Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-6840

xsd:import without schemaLocation does not get resolved in SchemaHandler

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 3.1.5
    • 3.1.6, 3.0.9, 3.2.0
    • JAX-RS
    • None
    • Unknown
    • Patch

    Description

      xsd:import without schemaLocation does not resolve in org.apache.cxf.jaxrs.utils.schemas.SchemaHandler using catalog.xml
      and "public" record (but works in cxf-wadl2java-plugin)

      Example xsd import:
      <xsd:import namespace="urn:some:namespace"/>
      Example catalog entry:

      <public publicId="urn:some:namespace"uri="classpath:schemas/some/namespace.xsd" />

      This doc says that <public> entry should be enough to resolve xsd:import without schemaLocation:
      https://jaxb.java.net/guide/Fixing_broken_references_in_schema.html

      Found where it takes place in case of cxf-wadl2java-plugin,
      please see SchemaCompilerImpl.bind(), it passes namespaceURI as publicId parameter, while SchemaHandler passes publicId as publicId, which is null, and resolve does not takes place.
      http://grepcode.com/file/repo1.maven.org/maven2/com.sun.xml.bind/jaxb-xjc/2.2.11/com/sun/tools/xjc/api/impl/s2j/SchemaCompilerImpl.java

      // XSOM passes the namespace URI to the publicID parameter.
      // we do the same here .
      InputSource is = opts.entityResolver.resolveEntity(namespaceURI, systemId);

      So I suppose this minor patch could fix SchemaHandler:
      replace
      resolvedLocation = catalogResolver.resolvePublic(publicId, systemId);
      with

      resolvedLocation = catalogResolver.resolvePublic(publicId!=null?publicId:namespaceURI, systemId);

      Also I can submit test project url if needed

      Attachments

        1. SchemaHandler.java.diff
          0.8 kB
          Vjacheslav Borisov

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            slavb18 Vjacheslav Borisov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: