public static void validate(XmlObject doc, boolean strict) throws XmlException {
        // Create an XmlOptions instance and set the error listener.
        Set<XmlError> validationErrors = new HashSet<>();
        XmlOptions validationOptions = new XmlOptions();
        validationOptions.setErrorListener(validationErrors);

        // Validate the XML document
        final boolean isValid = doc.validate(validationOptions);

        // Create Exception with error message if the xml document is invalid
        if (!isValid && !strict) {
            // check if we have special validation cases which could let the message pass anyhow
            validationErrors = filterToOnlySerious(validationErrors);
        }

        if (!validationErrors.isEmpty()) {
            throw new XmlException(createErrorMessage(validationErrors));
        }
    }
public static void validate(XmlObject doc, boolean strict) throws XmlException {
        
        Set<XmlError> validationErrors = new HashSet<>();
        XmlOptions validationOptions = new XmlOptions();
        validationOptions.setErrorListener(validationErrors);

        
        final boolean isValid = doc.validate(validationOptions);

        
        if (!isValid && !strict) {
            
            validationErrors = filterToOnlySerious(validationErrors);
        }

        if (!validationErrors.isEmpty()) {
            throw new XmlException(createErrorMessage(validationErrors));
        }
    }
public static void validate ( XmlObject doc , boolean strict ) throws XmlException { // Create an XmlOptions instance and set the error listener. Set < XmlError > validationErrors = new HashSet <> ( ) ; XmlOptions validationOptions = new XmlOptions ( ) ; validationOptions . setErrorListener ( validationErrors ) ; // Validate the XML document final boolean isValid = doc . validate ( validationOptions ) ; // Create Exception with error message if the xml document is invalid if ( ! isValid && ! strict ) { // check if we have special validation cases which could let the message pass anyhow validationErrors = filterToOnlySerious ( validationErrors ) ; } if ( ! validationErrors . isEmpty ( ) ) { throw new XmlException ( createErrorMessage ( validationErrors ) ) ; } }
Validates an xml doc. If the validation fails, the exception contains a detailed list of errors.

@param doc the document to validate
@throws XmlException thrown if the XML is incorrect
Validates an xml doc . If the validation fails the exception contains a detailed list of errors .