Updated: (XERCESJ-1258) Performance issue 2007-07-03 - By Michael Glavassevich (JIRA)
[ https://issues.apache.org/jira/browse/XERCESJ-1258?page=com.atlassian .jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Glavassevich updated XERCESJ-1258: ------------------------------------------
Component/s: (was: JAXP (javax.xml.validation)) XML Schema Structures Fix Version/s: (was: 2.6.2)
> Performance issue > ----------------- > > Key: XERCESJ-1258 > URL: https://issues.apache.org/jira/browse/XERCESJ-1258 > Project: Xerces2-J > Issue Type: Bug > Components: XML Schema Structures > Affects Versions: 2.6.2 > Environment: AIX > Reporter: Gerardo Corro > Priority: Blocker > > 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; > }
-- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
--------------------------------------------------------------------- To unsubscribe, e-mail: j-dev-unsubscribe@(protected) For additional commands, e-mail: j-dev-help@(protected)
|
|