OMR Marking normally consists of two or three different categories of marks. First consider that most OMR marking would need to be applied to a large package of documents like a single long PDF of 1000s of pages consisting of 100s of statements that could vary in page size.
There are marks based on page position in a single document in the package (like first page, last page), there are special marks based possible on something in the data (like the account balance is below $0 so it is printed on a red page) and lastly there are sequence marks which basically is a count 0 to 7, 0 to 7, 0 to 7 for the whole package independent of what statement it is processing. These last marks are used by high speed printers/sorters to validate things are happening as they should (ensuring all pages are being processed).
The easiest way to process this in XSL is to draw the first two types of marks in the document based on the respective rules. These are easy enough to do in the page template masters as they are either positional (first/last) or based on some XPATH data expression like "accountval < 0".
What we do in our solutions is to place a mark at all the other positions -- i.e. put down every 0 to 7 mark. Most all FO processers support processing the fo file to an intermediate representation which can be obtained from the engine serialized into an XML tree structure. This structure includes <page>
elements. It is here then you can do the work for the reminder of the marks.
Then it is simply a matter of going through the entire package and "removing" the structures in the logic for each page to make the sequence marks work.
This is the only way you can process a package of documents properly as the sequence marks will naturally cross individual statements in a package -- you may have a 2 page statement, followed by a 10 page statement, followed by a three page statement and you cannot guess at the processing of each where it starts/ends.
If you want to examine one implementation, you could download RenderX's VDPMill application. After install you will find a directory in the installation called "samples" with one of those samples named "OMR". It contains some sample XML and XSL showing an implementation for OMR for Pitney Bowes 8 Series and ABC Office 630 Series machines.