xsl-list
[Top] [All Lists]

[xsl] Best Way to Break Up Nested Structures Based On Inline Elements

2018-04-18 12:45:36
Using XSLT 2 with Saxon.

In the context of generating XSL-FO markup where there tree of fo:block 
elements can be quite deep, I need to break the blocks into a sequence of 
top-level blocks that specify @span based on the presence of markers anywhere 
in the heirarchy. This is to support FOP's strict implementation of the FO 
spec, which only allows specifying column spans on direct children of fo:flow.

In my processing I'm emitting marker elements to signal the starts and ends of 
areas that need to change the column spanning, e.g.:

<fo:block span="all">
  <fo:block>
     <fo:block>
       <fo:block>
          <two-column-start/>
      </fo:block>
      ...
     <two-column-end/>
   </fo:block>
  <fo:block>...
  </fo:block>
</fo:block>

Where the result needs to be:

<fo:block span="all">
   <!-- Stuff before two-column start -->
</fo:block>
<fo:block span="none">
   <!-- Stuff up to <two-column-end/> marker -->
</fo:block>
<fo:block span="all">
  <!-- Stuff after <two-column-end> marker -->
</fo:block>

There must be a general pattern for solving this kind of transformation pattern 
but I'm not seeing it or not remembering it.

I can think of a recursive algorithm to do it but is there a simpler or more 
efficient approach? Conceptually it's a for-each-group problem but the 
structure of the content doesn't see to lend itself to grouping.

Thanks,

Eliot
--
Eliot Kimber
http://contrext.com
 
--~----------------------------------------------------------------
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>