1. As a foreigner working in Spain you should be charged with the 25%
of your salary for tax purposes (for as long as you remain a fiscal
non-resident).
2. As a citizen from a country with a double imposition agreement with Spain you can avoid paying Spanish taxes during your visit (although you should by law declare those benefits in your country of residence) by bringing an official document stating that you pay taxes in your country. The document has to be issued by the competent tax institution in your country and written in Spanish, English or French. No other document will be accepted for that purpose.