+0
Hi,
I was told that a present or past progressive tense like "is sleeping" or "was sleeping" denotes a temporary action or activity and the present perfect or past perfect progressive is used to indicate duration.

I don't understand why a present progressive is one that denotes a temporary action and I don't particularily see clearly why a present perfect tense is the one that emphasizes (denotes strongly?) the element duration and a present progressive tense is not, if I interpreted what was told correctly.

Both of the two pairs in mixed tenses below seem to denote duration, not temporary actions per se.
eg,

John was sleeping when I walked in.
John had been sleeping when I walked in.

John is sleeping now.
John has been sleeping since morning.
+0
When you read that this or that tense "denotes a temporary action" or "denotes a sudden action" or "denotes duration" or "denotes a habitual activity" or any other of a number of impressionistic descriptions, you are reading poetry, in effect. These are only the suggestions of educators who are attempting to give the "flavor" of these tenses to those who, not being native speakers, have no idea what sort of information is conveyed by the use of one tense or another. These efforts are rather like those of a sighted person trying to describe a rainbow to a blind man. You may even have noticed that the descriptions tend to vary from one teacher to another, and they are not universally successful in bringing about understanding. If they help you get a start into the understanding of the tenses, these descriptions are good as a beginning, but ultimately you need to understand the tenses directly, without the mediation of impressionistic descriptions.
In short, in your place I would not take descriptions too seriously which give vague blanket descriptions attempting to contrast, for example, "temporary action" and "duration". The two are not even necessarily mutually exclusive, so it's difficult to see what point was being made by the person who wrote these descriptions. It seems to me that all actions have a certain duration and are temporary on some time scale or another, so these descriptions are somewhat mystifying.
It might be better to analyze the use of tenses in specific sentences rather than relying on limited descriptions that attempt to characterize each tense.
CJ
Comments  
John was sleeping when I walked in. At the moment of the action "I walked in", John was seen to be asleep.
Here there is no information about how long John slept, so there's nothing here involving duration or temporariness, except insofar as we know (outside of language) that sleeping takes some finite amount of time and does not last forever. What was noticed was the part of the sleeping that was "in midstream", i.e., neither the beginning (falling asleep) nor the ending (waking).
John had been sleeping when I walked in. At the moment of the action "I walked in", something was noticed which indicated that either "John was actually asleep" or "John, though awake, looked as if he had just woken from sleep". Here, what was noticed might have been either the sleeping "in midstream" or the later effects (after waking).
John is sleeping now. At the moment of the utterance, John is seen to be asleep.
Here there is again no information about how long John has been sleeping or how long he will continue to sleep, so there's nothing here involving duration or temporariness, except insofar as we know (outside of language) that sleeping takes time and does not last forever. Again, the sleeping is "in midstream" when it is noticed.

John has been sleeping since morning. At the moment of the utterance, it is known that John went to sleep earlier (during the morning of this day) and has continued to sleep without interruption until the moment of the utterance. Here the relative duration is specified. The sleeping is "in midstream" and there is some knowledge communicated about when the sleep episode began (morning).

CJ