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

xsd:import without schemaLocation does not get resolved in SchemaHandler

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 3.1.5
    • Fix Version/s: 3.1.6, 3.0.9, 3.2.0
    • Component/s: JAX-RS
    • Labels:
      None
    • Estimated Complexity:
      Unknown
    • Flags:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: