To say that a region trying to forge independence is illegal is true by definition because wherever you are the law will enshrine the status quo, but it's not a meaningful statement.
And to say that there's no choice but to apply the law isn't true, when it comes to questions this big the system of: make law=> judicial system interprets=> police enforce breaks down, because it's a political question not a legal question. Eg. how Uber in London is implicitly political, it's too big to be held by courts and keep politicians out. Spanish politicians absolutely had some leeway in how they dealt with this.