how could this trans happen with 0 trans but only generate one
Because that is how bitcoin is designed to work.
is there any method to avoid it ?
As a solo miner or a mining pool operator, you can choose which transactions you want to confirm (if any). As a non-mining user? Nope. Nothing you can do about it.
There should be some rules , for example , at least xxx trans or xx% of all unconfirmed trans
There is.
The rule is:
"At least 1 transaction"
Specifically, the block MUST include a generation transaction.
if I Am a minner can I set up the trans number while I am minning .or it is random?
If you are solo-mining, or you are operating a mining pool, then yes. If you are just a miner mining in a pool that someone else is operating, then typically no.
almost clear.
so if I am a minner solo-mining. and I can set up the block, I will mined, by all 0 trans( just the generation transaction)
if this happened the number of unconfirmed trans will be stay there or just become more.
it is bad.