public static boolean isValidSchematron (@Nullable final Source aSource)
  {
    if (aSource == null)
      return false;

    try
    {
      // Get a validator from the RNC schema.
      final Validator aValidator = RelaxNGCompactSchemaCache.getInstance ().getValidator (SCHEMATRON_RNC);

      // Ensure a collecting error handler is set
      final ErrorHandler aOldEH = aValidator.getErrorHandler ();
      CollectingSAXErrorHandler aCEH;
      if (aOldEH instanceof CollectingSAXErrorHandler)
        aCEH = (CollectingSAXErrorHandler) aOldEH;
      else
      {
        aCEH = new CollectingSAXErrorHandler ();
        aValidator.setErrorHandler (aCEH.andThen (aOldEH));
      }

      // Perform validation
      aValidator.validate (aSource, null);

      // Check results
      return aCEH.getErrorList ().getMostSevereErrorLevel ().isLT (EErrorLevel.ERROR);
    }
    catch (final SAXException ex)
    {
      // Document is not valid in respect to XML
    }
    catch (final IOException ex)
    {
      LOGGER.warn ("Failed to read source " + aSource, ex);
    }
    return false;
  }
public static boolean isValidSchematron (@Nullable final Source aSource)
  {
    if (aSource == null)
      return false;

    try
    {
      
      final Validator aValidator = RelaxNGCompactSchemaCache.getInstance ().getValidator (SCHEMATRON_RNC);

      
      final ErrorHandler aOldEH = aValidator.getErrorHandler ();
      CollectingSAXErrorHandler aCEH;
      if (aOldEH instanceof CollectingSAXErrorHandler)
        aCEH = (CollectingSAXErrorHandler) aOldEH;
      else
      {
        aCEH = new CollectingSAXErrorHandler ();
        aValidator.setErrorHandler (aCEH.andThen (aOldEH));
      }

      
      aValidator.validate (aSource, null);

      
      return aCEH.getErrorList ().getMostSevereErrorLevel ().isLT (EErrorLevel.ERROR);
    }
    catch (final SAXException ex)
    {
      
    }
    catch (final IOException ex)
    {
      LOGGER.warn ("Failed to read source " + aSource, ex);
    }
    return false;
  }
public static boolean isValidSchematron ( @ Nullable final Source aSource ) { if ( aSource == null ) return false ; try { // Get a validator from the RNC schema. final Validator aValidator = RelaxNGCompactSchemaCache . getInstance ( ) . getValidator ( SCHEMATRON_RNC ) ; // Ensure a collecting error handler is set final ErrorHandler aOldEH = aValidator . getErrorHandler ( ) ; CollectingSAXErrorHandler aCEH ; if ( aOldEH instanceof CollectingSAXErrorHandler ) aCEH = ( CollectingSAXErrorHandler ) aOldEH ; else { aCEH = new CollectingSAXErrorHandler ( ) ; aValidator . setErrorHandler ( aCEH . andThen ( aOldEH ) ) ; } // Perform validation aValidator . validate ( aSource , null ) ; // Check results return aCEH . getErrorList ( ) . getMostSevereErrorLevel ( ) . isLT ( EErrorLevel . ERROR ) ; } catch ( final SAXException ex ) { // Document is not valid in respect to XML } catch ( final IOException ex ) { LOGGER . warn ( "Failed to read source " + aSource , ex ) ; } return false ; }
Check if the passed source is a valid schematron instance.

@param aSource
The source to check. May be <code>null</code>.
@return <code>true</code> if the schematron is valid, <code>false</code>
otherwise.
Check if the passed source is a valid schematron instance .