PDF Landscape page-sequence XSL:FO #PDF #FOP


I´ve been working on landscape for my custom PDF transformation for few months now (on and off project). I´ve picked it up again few days ago and I´m pretty close I think.
What I´m trying to do is detect if outputclass="landscape" was set for the topic and if yes process it in landscape mode, otherwise the page-sequence should stay default. So far this works very well, but not exactly how i want it to. I´ve implemented it in that way that by every topic processing, it checks which outputclass is defined and based on that it creates new <fo:page-sequence>. I just couldn´t find a better way when i started. The problem is that every page has its own page-sequence and this is a problem when I have a .dita file whos content covers only few rows of A4 paper. What I want to achieve is to just continue next .dita file after this paragraph in case the outputclass was same as the previously processed topic. I just can´t wrap my head around a right solution...

I´m hoping someone more experienced could help me with this matter and point me in right direction.

Here is my code: