> We're putting our texts into the eXist database. We want to be able
> to show one page of the original text at the time, so we'll be needing
> an XQuery expression to retrieve the specific portion of a text, namely
> between two specific <pb/>'s. Problems arise when the <pb/> fall in
> the middle of another element, say, a <p>. There might also be a
> <div>-break on the middle of the page, etc.
Dealing with two intersecting hierarchies is a problem CorpusReader try to help
to deal with (can I say that?), see:
(the doc is in french but there is samples). The idea is to be able to convert
into "normal" element any milestoned element (such as "pb") -- if necessary,
converting into milestone the element conflicting with this created elements.
For instance, with a rule such as:
<filter name="foo" javaClass="tei.cr.filters.ExtractMilestone">
<startBoundary elxpath="tei:pb" />
You can transform this tree:
<p> <!-- first paragraph -->
<pb/> <!-- boundary between first and second page -->
<p> <!-- second paragraph -->
<pb/> <!-- boundary between second and third page -->
Into this one:
<pb> <!-- first page -->
<p> <!-- first paragraphe... -->
<pb> <!-- second page -->
<p> <!-- first paragraphe, cont. -->
<p> <!-- second paragraphe -->
<pb> <!-- third page -->
<p> <!-- second paragraphe, cont. -->
The conversion between milestone/hierarchy is done using the SAX API, which
is far more suited for this purpose than the DOM API (used by XPath), since
the precedence order is more usefull than the dominance order for identifying
and transforming milestones.
If you're interested with this solution, let me know, I'm currently rewriting all
this code for adding various milestone scheme support.