3 Replies Latest reply on Mar 11, 2009 3:33 AM by Daniel Bevenius

    Schema validation in ActionProcessingPipeline is too restric

    Morten Hattesen Newbie

      The declarative schema validation feature that has been added to the ActionProcessingPipeline via the "validate", "inXsd" and "outXsd" tags can only validate the most simple of schemas.

      Due to the way the schema references are resolved in org.jboss.internal.soa.esb.util.XMLHelper.getSchema(String)) any xsd:import with a relative URL specifier will fail to load

      Firstly, the schema specifiers (inXsd/outXsd) should allow classpath resources as well as URL's (file:, http: ...).

      In case of a classpath resource specifier, its url should be resolved using ClassUtil.getResource().

      A Schema instance then need to be loaded from the schema URL, allowing xsd:import's with relative URLs to be resolved.

      In XMLHelper, the getSchema() method may be modified like so (not tested):


      public static Schema getSchema(final String resource)
      throws SAXException
      {
      //final InputStream resourceIS = ClassUtil.getResourceAsStream(resource, XMLHelper.class) ;
      //return SCHEMA_FACTORY.newSchema(new StreamSource(resourceIS)) ;
      URL schemaUrl;
      try {
      // assume resource is valid URL
      schemaUrl = new URL(resource);
      } catch (MalformedURLException e) {
      // resource is not a valid URL, assume it is a classpath reference
      schemaUrl = ClassUtil.getResource(resource, XMLHelper.class);
      if (schemaUrl == null) {
      throw new SAXException("Unable to locate schema resource " + resource);
      }
      }
      return SCHEMA_FACTORY.newSchema(schemaUrl);
      }



      ... a similar change must be made to the getSchema(String[]) method.