A revolution is, by definition, illegal. A revolution is the violent overthrow of the existing government (or state) by means of insurrection. A republic could be established legally by act of Parliament, but as ansteyg says, that would not be a revolutionary process. In terms of the wording of your question, a revolution within a democratic society is not democratic; although it would be possible to have a revolution within an undemocratic state for the purpose of establishing a democracy.