xsl-list
[Top] [All Lists]

Re: [xsl] breaking up XML on page break element

2014-07-04 10:18:44
I tackle it by what I call “upward projection”:

When processing the top-level element, do a for-each-group of all descendants that are terminal nodes (those without children), with a group-starting-with at the splitting points.

For each group, process the book (or the HTML body, or whatever common ancestor there is) once in another mode, with a tunneled parameter 'restricted-to' that contains, for each group, the terminal nodes and their ancestors.

When processing each group, for each node that you encounter, test whether the node is contained in the tunneled variable (using intersect). If it is, reproduce the node and continue in this mode, if it isn’t contained, do nothing.

There may be an option to discard or to reproduce the splitting elements.

Examples for this technique are in https://subversion.le-tex.de/common/evolve-hub/evolve-hub.xsl, modes hub:split-at-tab and hub:split-at-br

They are a bit more complex than your case because they split paragraphs that may contain tables or footnotes that in turn can contain other paragraphs. I introduced the function hub:same-scope($splitting-element, $containing-element) to split only at splitting elements that are contained within the paragraph that should be split, rather than in a paragraph that is contained in a footnote or table cell that is somehow contained in the given paragraph.

I might prepare a synthetic standalone example if anyone is interested, and furthermore on the condition that interested parties root for Germany instead of France today.

Gerrit

On 04.07.2014 16:43, Geert Bormans geert(_at_)gbormans(_dot_)telenet(_dot_)be 
wrote:
Hi all,

Here is a fun one I thought I could share

I have a nicely nested XML (a bit TEI like)
and markers for page breaks can happen everywhere in the document (as
empty elements)

Now I want to break the document per page, reconstructing the structure
So in a first step, I want to isolate the pagebreak to the highest level

<book>
<title>...</title>
<section>
<para>aaa<pb/>bbb</para>
</section>
</book>

to become

<book>
<title>...</title>
<section>
<para>aaa</para>
</section>
<pb/>
<section>
<para>bbb</para>
</section>
</book>

Bearing in mind I need a generic solution
and pagebreaks can happen at every level

Any thoughts?
I am not looking for code, just curious on how people would attack this

Thanks

Geert


--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>