Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-1258

Performance issue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Invalid
    • 2.6.2
    • None
    • None
    • AIX

    Description

      The following snippet cuases tremendous CPU consumption, one xml file of 1Mb size and schema size of 33kb can take up to one hour to be validated.

      This problem does not occur in windows, but happens in AIX.

      private boolean validateXmlVsSchema(String SchemaUrl, String xmlString) throws ValidationException, SAXParseException, UnhandleableException {

      File schema = new File(SchemaUrl);
      log.debug("The schema is being searched at: " + SchemaUrl);
      if ( !schema.exists() ) {
      throw new UnhandleableException(ValidatorConstants.SCHEMA_NO T_FOUND_EXCEPTION,
      new Exception(ValidatorConstants.SCHEMA_NOT_FOUND_EXCE PTION));
      }

      SAXParser parser = new SAXParser();
      try{
      parser.setFeature("http://xml.org/sax/features/validation", true);
      parser.setFeature("http://apache.org/xml/features/validation/schema", true);
      parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
      parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", SchemaUrl );
      Validator handler = new Validator();
      parser.setErrorHandler(handler);
      InputStream is = new ByteArrayInputStream( xmlString.getBytes("UTF-8"));
      parser.parse(new InputSource(is));
      if(handler.validationError==true){
      log.error(clazzName + "-> " + ValidatorConstants.SCHEMA_VALIDATION_ERROR + ": " + handler.validationError +
      "" + handler.saxParseException.getMessage(), handler.saxParseException);
      throw handler.saxParseException;
      } else {
      log.debug(clazzName + "-> " + ValidatorConstants.DOCUMENT_VALIDATED );
      return true;
      }
      } catch( java.io.UTFDataFormatException utfex){
      log.info(clazzName + "-> Wrong utf: " + utfex.getMessage(), utfex );
      } catch(java.io.IOException ioe){
      log.error(clazzName + "-> IOException " + ioe.getMessage(), ioe);
      throw new ValidationException(ValidatorConstants.SCHEMA_VALI DATION_EXCEPTION, ioe);
      } catch (SAXParseException e) {
      log.error(clazzName + "-> SAXParseException " + e.getMessage(), e);
      throw e;
      } catch (SAXNotRecognizedException e) {
      log.error(clazzName + "-> SAXNotRecognizedException " + e.getMessage(), e);
      throw new ValidationException(ValidatorConstants.SCHEMA_VALI DATION_EXCEPTION, e);
      } catch (SAXNotSupportedException e) {
      log.error(clazzName + "-> SAXNotSupportedException " + e.getMessage(), e);
      throw new ValidationException(ValidatorConstants.SCHEMA_VALI DATION_EXCEPTION, e);
      } catch (SAXException e) {
      log.error(clazzName + "-> SAXException " + e.getMessage(), e);
      throw new ValidationException(ValidatorConstants.SCHEMA_VALI DATION_EXCEPTION, e);
      }
      return true;
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            gcorro Gerardo Corro
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: