    /*
     * call-seq:
     *  validate_file(filename)
     *
     * Validate a file against this Schema.
     */
    static VALUE validate_file(VALUE self, VALUE rb_filename)
    {
      xmlSchemaPtr schema;
      xmlSchemaValidCtxtPtr valid_ctxt;
      const char *filename ;
      VALUE errors;

      Data_Get_Struct(self, xmlSchema, schema);
      filename = (const char*)StringValuePtr(rb_filename) ;

      errors = rb_ary_new();

      valid_ctxt = xmlSchemaNewValidCtxt(schema);

      if(NULL == valid_ctxt) {
        /* we have a problem */
        rb_raise(rb_eRuntimeError, "Could not create a validation context");
      }

    #ifdef HAVE_XMLSCHEMASETVALIDSTRUCTUREDERRORS
      xmlSchemaSetValidStructuredErrors(
        valid_ctxt,
        Nokogiri_error_array_pusher,
        (void *)errors
      );
    #endif

      xmlSchemaValidateFile(valid_ctxt, filename, 0);

      xmlSchemaFreeValidCtxt(valid_ctxt);

      return errors;
    }