Re: [xsl] Splitting XHTML by elements that have page-breaks

Subject: Re: [xsl] Splitting XHTML by elements that have page-breaks
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 16 Sep 2009 11:01:46 -0400
Martynas,

If your sibling recursion is very complex, it can be managed more easily by separating the process into two phases. Phase one marks the places where the splitting has to occur. (For example, you could use attribute flags on the elements starting the new chunk.) Phase two performs the sibling recursion, splitting at those places (looking for the attribute flags, not something else).

This way all the logic controlling where the splitting should happen is separate from the sibling recursion, which tends to make it much easier to see, extend and maintain.

In XSLT 2.0, where we can use for-each-group instead of sibling recursion, the same encapsulation can be achieved using a function.

Cheers,
Wendell

At 07:24 PM 9/15/2009, you wrote:
Hey list,

I asked recently how to split a big XHTML file into several chunks
(under 300 KB) for use in ePub. I have that problem semi-solved -- I
decided to go the easier route and split the file into chapters, and
the chunks turned out to be well less than 300 KB, so I'll stick to
that so far.

I used sibling recursion on html:h1 elements, and that worked fine.
But now I need not only headings to be used for splitting, but many
more elements, e.g. html:p[@class = 'Quote'] -- actually all those
that have page-breaks defined in their styles.

The styles are defined in a separate style.xml file which comes from
ODT. Style names become CSS classnames in XHTML, so I can check by
@class value if a style has a page-break:
document('styles.xml')//style:style[@style:name =
'Quote']/style:paragraph-properties/@fo:break-before = 'page'

And here comes the question -- how can I define sibling recursion not
only on html:h1, but on html:* that have page-breaks? I hope it's
possible to understand..

Thanks,

Martynas
semantic-web.dk


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread