In Spain, along with any other country you are to pay income tax on what you earn and on your assets. This tax is usually paid in the country where you live and/or work, being the most logical as that is where your income originates from. So just like you are assessed on your income and assets, by having assets in Spain, regardless of whether you earn from you are eligible for Spanish income tax.
It is normal that non-residents brought in Spain either for a holiday home or as an investment. If your assets in Spain consist of only one property and you gain no income from it, then your income tax will be relatively small and easy to pay. If your assets in Spain do generate income then you will have to declare not only the property, but the money made from it. Both property and income made from it, have a taxable percentage. The amount of taxable income will depend on a threshold limit before you have to pay, however properties are automatically taxable. The income you are able to generate here in Spain through the investments you have made will and should be tax here in Spain, and therefore if you wanted to take the money out of the country, you could. You could take money out because it has been taxed appropriately as well as having been declared, so it is all legal. As long as the new destination of the funds formed part of the double taxation agreement with Spain, then you will not pay income tax again in another country as the money has already been taxed.
Income tax has to be presented in Spain when you own a property and you must pay the small taxes involved. If in the future you wanted to sell you will need to prove that you have paid your taxes up to date and this includes income tax, if not then you will of course have to clear the debt which may create problems with the sale.
Income tax is to be calculated through your tax return declaration, where you will then find out if you owe taxes, owe nothing, or are to be refunded for paying more than needed.