Gap solitons and Bloch waves in nonlinear periodic systems