I'm working on an XSLT to transform XML (tei) docs to HTML. The goal is to create divs that can be styled to display as fixed columns.
In the docs, column beginnings are indicated by 2 empty elements (milestone and cb). "milestone" indicates that the number of columns, in the text flow, is now equal to the n attribute. "cb" marks the beginning of a column, and its n attribute indicates its order in the left-to-right sequence. The "cb" tags are not always siblings.
sample xml:
<p>
<milestone unit="column" n="2"/>
<cb n="1"/>
M. Dudley
<lb/>
H. E. Ernshimer
<lb/>
M. M. Cash
<lb/>
John Wheatly
<lb/>
Jno W. Cash
<lb/>
<cb n="2"/>
R. L. Wilson
<lb/>
R. B. Ratliff L.C.C.
<lb/>
G. D Watkins Clk
<lb/>
A. C. Mayes
<lb/>
<pb/>
</p>
<p>
<note place="left margin">Jury 1863 Nov.</note>
<lb/>
<cb n="1"/>
D C Mitchenssson
<lb/>
A. W. Forde, Tm P
<lb/>
L S Thomson
<lb/>
Louis Martin
<hi rend="sup">c</hi>
Casslin
<lb/>
E. M. Stevens
<lb />
<cb n="2"/>
O Ross Baker Clk Caldwell County Court
<lb/>
N. Jones
<lb/>
S. W. M
<milestone unit="column" n="1"/>
<pb/>
<lb/>
John Garrett
</p>
Desired result below. divs with class equal to their preceding milestone's n attribute:
<div class="column 2">
M. Dudley<br />
H. E. Ernshimer<br />
M. M. Cash<br />
John Wheatly<br />
Jno W. Cash<br />
...
</div>
<div class="column 2">
R. L. Wilson<br />
R. B. Ratliff L.C.C.<br />
G. D Watkins Clk<br />
A. C. Mayes<br />
Jas Crenshaw<br />
</div>
How can I grab everything between each pair of cb tags, and wrap the content in a containing div? Everything I've tried results in a series of nested divs.