public boolean validate() { return underlyingXmlObject().validate(); }
public boolean validate(XmlOptions options) { return underlyingXmlObject().validate(options); }
result = false; else if (xobj.validate(new XmlOptions().setErrorListener(errors))) System.out.println("Instance[" + i + "] valid - " + instances[i].documentProperties().getSourceName()); else
System.out.println(" Document type not found." ); else if (xobj.validate(strict ? new XmlOptions().setErrorListener(errors).setValidateStrict() : new XmlOptions().setErrorListener(errors)))
XmlOptions voptions = new XmlOptions(); voptions.setErrorListener(StscState.get().getErrorListener()); if (!(xdoc instanceof SchemaDocument) || !xdoc.validate(voptions))
if (!instance.validate(new XmlOptions().setErrorListener(errors))) instanceValid = false;
schemas[k].validate(opts))
if (configdoc.validate(new XmlOptions().setErrorListener(errorListener)))
public boolean validate(XmlOptions options) { return underlyingXmlObject().validate(options); }
if (!(xdoc instanceof SchemaDocument) || !xdoc.validate(voptions))
public boolean validate() { return underlyingXmlObject().validate(); }
public boolean validate(XmlOptions options) { return underlyingXmlObject().validate(options); }
public boolean validate() { return underlyingXmlObject().validate(); }
/** * Performs validation on the XmlBean, populating the error message if failed. * @return false if the XmlBean is invalid (error message is available in getValidationError()). */ public boolean validate() { _validationError = null; List<XmlError> errors = new ArrayList<XmlError>(); boolean valid = _xmlBean.validate(new XmlOptions().setErrorListener(errors)); if (!valid) { _validationError = ""; for (int i = 0; i < errors.size(); i++) { _validationError += errors.get(i).toString(); if (i < errors.size() - 1) _validationError += '\n'; } } return valid; }
private void throwExceptionIfSchemaValidationFails(XmlObject theBean, String sourceDescription) throws XmlException { List errors = new ArrayList(); XmlOptions options = new XmlOptions(); options = options.setLoadLineNumbers(); options = options.setErrorListener(errors); options = options.setDocumentSourceName(sourceDescription); boolean validated = theBean.validate(options); if (errors.size() > 0 || (!validated)) { StringBuffer descrip = new StringBuffer(); descrip.append("The configuration from '" + sourceDescription + "' is invalid; it has " + errors.size() + " error" + (errors.size() == 1 ? "" : "s") + ":\n"); int pos = 1; Iterator iter = errors.iterator(); while (iter.hasNext()) { descrip.append(" " + pos + ": " + iter.next().toString() + "\n"); pos++; } throw new XmlException(descrip.toString()); } }
private void throwExceptionIfSchemaValidationFails(XmlObject theBean, String sourceDescription) throws XmlException { List errors = new ArrayList(); XmlOptions options = new XmlOptions(); options = options.setLoadLineNumbers(); options = options.setErrorListener(errors); options = options.setDocumentSourceName(sourceDescription); boolean validated = theBean.validate(options); if (errors.size() > 0 || (!validated)) { StringBuffer descrip = new StringBuffer(); descrip.append("The configuration from '" + sourceDescription + "' is invalid; it has " + errors.size() + " error" + (errors.size() == 1 ? "" : "s") + ":\n"); int pos = 1; Iterator iter = errors.iterator(); while (iter.hasNext()) { descrip.append(" " + pos + ": " + iter.next().toString() + "\n"); pos++; } throw new XmlException(descrip.toString()); } }
private void throwExceptionIfSchemaValidationFails(XmlObject theBean, String sourceDescription) throws XmlException { List errors = new ArrayList(); XmlOptions options = new XmlOptions(); options = options.setLoadLineNumbers(); options = options.setErrorListener(errors); options = options.setDocumentSourceName(sourceDescription); boolean validated = theBean.validate(options); if (errors.size() > 0 || (!validated)) { StringBuffer descrip = new StringBuffer(); descrip.append("The configuration from '" + sourceDescription + "' is invalid; it has " + errors.size() + " error" + (errors.size() == 1 ? "" : "s") + ":\n"); int pos = 1; Iterator iter = errors.iterator(); while (iter.hasNext()) { descrip.append(" " + pos + ": " + iter.next().toString() + "\n"); pos++; } throw new XmlException(descrip.toString()); } }
/** * Validates an xml doc. If the validation fails, the exception contains a * detailed list of errors. * * @param doc the document to validate * @throws XMLHandlingException thrown if the XML is incorrect */ public static void strictValidate(final XmlObject doc) throws XMLHandlingException { if (!validationGlobally) { return; } final List<XmlError> validationErrors = new ArrayList<>(); final XmlOptions validationOptions = new XmlOptions(); validationOptions.setErrorListener(validationErrors); final boolean isValid = doc.validate(validationOptions); // create XmlException with error-message if the XML is invalid. if (!isValid) { throw new XMLHandlingException("Invalid xml content\n", validationErrors); } }
private void validateDD(XmlObject dd) throws XmlException { XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setDocumentType(DirDirectoryConfigurationDocument.type); xmlOptions.setLoadLineNumbers(); xmlOptions.setUseDefaultNamespace(); Collection errors = new ArrayList(); xmlOptions.setErrorListener(errors); if (!dd.validate(xmlOptions)) { throw new XmlException("Invalid directory descriptor: " + errors + "\nDescriptor: " + dd.toString(), null, errors); } // System.out.println("descriptor: " + dd.toString()); } }
public static InputStream createInputStream(XmlObject xmlObject, boolean writeXMLDeclaration) throws GenericException, ValidationException { // Create an XmlOptions instance and set the error listener. XmlOptions validateOptions = new XmlOptions(); List<XmlValidationError> errorList = new ArrayList<>(); validateOptions.setErrorListener(errorList); // Validate the XML. boolean isValid = xmlObject.validate(validateOptions); if (isValid) { XmlOptions xmlSaveOptions = new XmlOptions().setUseDefaultNamespace().setSavePrettyPrint() .setSaveAggressiveNamespaces(); if (!writeXMLDeclaration) { xmlSaveOptions = xmlSaveOptions.setSaveNoXmlDecl(); } return xmlObject.newInputStream(xmlSaveOptions); } else { throw new ValidationException(xmlValidationErrorsToValidationReport(errorList)); } }