We consider a semimartingale X which is reflected at an upper barrier T and a lower barrier S, where S and T are also semimartingales such that T is bounded away from S. First, we present an explicit construction of the reflected process. Then we derive a relationship in terms of stochastic integrals linking the reflected process and the local times at the respective barriers to X, S, and T. This result reveals the fundamental structural properties of the reflection mechanism. We also present a few results showing how the general relationship simplifies under additional assumptions on X, S, and T, e.g. if we take X, S, and T to be independent martingales (which satisfy some extra technical conditions).