I'm not sure what you mean by a page number. Are pages something that exist in your XML file, perhaps as <page> elements, or are they something that comes into existence when the XML is rendered, e.g. using XSL-FO?
If the pages exist as <page> elements then it's easy to add a page number using a simple XSLT transformation.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference