List of usage examples for javax.xml.transform.stream StreamSource setPublicId
public void setPublicId(String publicId)
From source file:ar.com.tadp.xml.rinzo.core.resources.validation.XMLStringValidator.java
private void saxSchemaValidate(String fileName, String fileContent, Collection<DocumentStructureDeclaration> schemaDefinitions) { try {//from w ww .j a v a2 s .c o m Validator validator; Map<Collection<DocumentStructureDeclaration>, Validator> schemaValidatorsCache = XMLEditorPlugin .getDefault().getSchemaValidatorsCache(); validator = schemaValidatorsCache.get(schemaDefinitions); if (validator == null) { StreamSource[] sources = new StreamSource[schemaDefinitions.size()]; int pos = 0; Map<String, String> fileLocations = DocumentCache.getInstance().getAllLocations(schemaDefinitions, fileName); for (Map.Entry<String, String> fileLocation : fileLocations.entrySet()) { StreamSource streamSource = new StreamSource(fileLocation.getValue()); streamSource.setPublicId(fileLocation.getKey()); sources[pos++] = streamSource; } validator = this.createValidator(sources); schemaValidatorsCache.put(schemaDefinitions, validator); } validator.reset(); validator.setErrorHandler(this.errorHandler); validator.validate(new StreamSource(new StringReader(fileContent))); } catch (SAXParseException saxE) { try { this.errorHandler.error(saxE); } catch (SAXException e) { } } catch (Exception exception) { //Do nothing because the errorHandler informs the error } }