Applause broke out in the Catalan parliament and on the streets as a vote in favour of declaring independence was announced.