DE DEFECTIBUS, Papal Bull decreed by Pope Saint Pius V in ratifying the Council of Trent states,
The intention of consecrating is required. Therefore there is no consecration in the following cases: when a priest does not intend to consecrate but only to make a pretense;.. (http://www.dailycatholic.org/defectib.htm)
This is understood quite loosely lest it be scandalous (one would have to know that a priest really believes in transubstantiation for it to be efficacious), so that just having general intention to baptize or celebrate the Eucharist is said to suffice, even if the priest does not believe in transubstantiation.
However, the The Catholic Encyclopedia states on>intention:
The Church teaches very unequivocally that for the valid conferring of the sacraments, the minister must have the intention of doing at least what the Church does. This is laid down with great emphasis by the Council of Trent (sess. VII). The opinion once defended by such theologians as Catharinus and Salmeron that there need only be the intention to perform deliberately the external rite proper to each sacrament, and that, as long as this was true, the interior dissent of the minister from the mind of the Church would not invalidate the sacrament, no longer finds adherents. The common doctrine now is that a real [virtual at least] internal intention to act as a minister of Christ, or to do what Christ instituted the sacraments to effect, in other words, to truly baptize, absolve, etc., is required. (www.newadvent.org/cathen/08069b.htm)
"One indeed is the universal Church of the faithful, outside which no one at all is saved, in which the priest himself is the sacrifice, Jesus Christ, whose body and blood are truly contained in the sacrament of the altar under the species of bread and wine; the bread (changed) into His body by the divine power of transubstantiation, and the wine into the blood, so that to accomplish the mystery of unity we ourselves receive from His (nature) what He Himself received from ours."
--Pope Innocent III and Lateran Council IV (A.D. 1215)
"We are compelled in virtue of our faith to believe and maintain that there is only one holy Catholic Church, and that one is apostolic. This we firmly believe and profess without qualification. Outside this Church there is no salvation and no remission of sins, the Spouse in the Canticle proclaiming: 'One is my dove, my perfect one. One is she of her mother, the chosen of her that bore her' (Canticle of Canticles 6:8); which represents the one mystical body whose head is Christ, of Christ indeed, as God. And in this, 'one Lord, one faith, one baptism' (Ephesians 4:5). Certainly Noah had one ark at the time of the flood, prefiguring one Church which perfect to one cubit having one ruler and guide, namely Noah, outside of which we read all living things were destroyed We declare, say, define, and pronounce that it is absolutely necessary for the salvation of every human creature to be subject to the Roman Pontiff."
--Pope Boniface VIII, Bull Unam sanctam (A.D. 1302)