The Spanish government has sacked Catalonia's president and dismissed its parliament hours after the region declared independence.