I would like to convert a collection of digitized documents to Mathematica notebooks. They are formatted as XML, divided into pages. The XML contains formatting I would like to preserve, but I do not want to display page divisions, in other words I would like the text to flow like a typical notebook. However, I would like to use a docked cell to display the page range of any text that is selected. A text selection could come from a single page or multiple pages.
My question is, what is the best way to represent this data? I imagine StyleBoxes and TagBoxes (to hold page numbers) but I don't have a clear understanding of how these interact. When I try to nest one inside the other (TaxBox[StyleBox[...]] or StyleBox[TagBox[...]]) I end up with cells that just print as expressions. I also imagine I could use InterpretationBoxes to store the formatted text and then a hidden duplicate copy with the page information added, but that is so inefficient I have to believe there is a better way.
Here's an example. What would be a good way to represent this text? Say it spans pages 1-2, divided at ///.
A sentence that spans two /// pages and has some mixed formatting.
EDIT:
The following code almost works, but the way it behaves when I try to select text with my mouse is off.
Cell[BoxData@RowBox[{
TagBox[RowBox[{
StyleBox["A sentence", "Text"],
StyleBox["that spans two", "Text", FontWeight -> "Bold"]
}], "Page1"],
TagBox[RowBox[{
StyleBox["pages", "Text", FontWeight -> "Bold",
FontSlant -> "Italic"],
StyleBox["and has some mixed formatting.", "Text"]
}], "Page2"]
}]] // CellPrint
If I place the cursor on the left side of this sentence and drag toward the right, once I pass "two" the entire right-side box becomes selected. So, for example, I cannot select "two pages" using my cursor. I understand this is related to the hierarchical nature of the underlying expressions; is there something that can be done about it? Or is there an alternative representation that will avoid this problem?