Re: [xep-support] Selecting everything "before" and "after" a given node

From: Dan Ochs <dan.ochs@gmail.com>
Date: Tue Mar 31 2009 - 05:41:25 PST

I had to do this for an implementation using xsl 1.0 before but forpage sequences for different page sizes and layout for "foldouts," andit is NOT simple, assuming your "spanTable" can be located anywhere inthe xsl-fo node tree. You may be able to simplify your case though,since each implementation is different and you may have differentrequirements in the end.
Here is a basic algorithm you need to implement:1. generate your xsl-fo as you normally do2. post process the xsl-fo and look for all of the tables withspan="all" as Ken mentioned.3. process each of these "spanTables" a. retrieve all nodes before the current spanTable and after theprevious spanTable, unless this is the first spanTable, then you wantall nodes before it. b. retrieve all nodes after the current spanTable and before thenext spanTable, unless this is the last spanTable, then you want allnodes after it.4. process the nodes before the current spanTable and if any of thosenodes contain the spanTable as a descendant, close them off before thespanTable is reached.5. output the current spanTable content6. process the nodes after the current spanTable, elements thatcontain the span table will need to be re-opened.
Things to keep in mind:1. You will need special handling for the fo:list constructs if thespanTable occurs within a list.2. You do not need to modify the page-sequence in your case, so onlynodes below the page-sequence should need to be modified.
I'm sure there are things I'm missing, if you have any questions feelfree to contact me.

thanks, dan

Dan Ochs, Principal ConsultantWrycan, Inc.http://xsl.wrycan.comdan(dot)ochsatwrycan(dot)com

On Mon, Mar 30, 2009 at 4:14 PM, Harvey, Paul <Paul_Harvey@omb.eop.gov> wrote:> Hi,>>>> This one’s got me stumped, but perhaps it’s simpler than I think.>>>> We have XML something like this (this is very much simplified)>>>> <chapter>>>       <account>>>             <bureau>>>                   <fund>>>                         <table>...</table>>>                   </fund>>>                   <fund>>>                         <table>...</table>>>                   </fund>>>             </bureau>>>             <bureau>>>                   <fund>>>                         <table>...</table>>>                   </fund>>>                   <fund>>>                         <table type=”BREAK-OUT”><!-- THIS NEEDS TO BE BROKEN> OUT !
 --></table>>>                   </fund>>>                   <fund>>>                         <table>...</table>>>                   </fund>>>             </bureau>>>             <bureau>>>                   <fund>>>                         <table>...</table>>>                   </fund>>>             </bureau>>>       </account>>>       <account>...</account>>> </chapter>>>>> In our XSL:FO we have (again simplified)>>>> ...>> <fo:flow>>>    <xsl:apply-templates/>>> </fo:flow>>> ...>>>> But we have a special case now in which the table highlighted above needs to> span two columns. To do this we need to put it in a block which is a child> of the flow.>> Our existing template structure deeply nests stuff in blocks, wrappers and> inlines, so we need to be able to break the table out by doing something> alon!
 g the lines of…>>>> ...>> <fo:flow>>>       <xsl:apply-t!
emplates select=”Nodeset of all nodes before the table in> question”/>>>       <fo:block span="all">>> <xsl:apply-templates select=”//table[@type=’BREAK-OUT’]”/>>>       </fo:block>>> <xsl:apply-templates select=”Nodeset of all nodes after the table in> question”/>>> </fo:flow>>> ...>>>> Conceptually this seems reasonable enough, but in playing around with> various axis (preceding/following/ancestor and unions thereof) I’ve not got> it yet.>>>> Does anyone have any suggestions, or is there a nice idiom for what I’m> trying to do?>>>> By the way, the stylesheet is large and complex and I’m hoping to find away> to select what I want and have existing code handle it, with a minimal of> changes to existing code.>>>> Thanks very much,>>>> Paul
-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/terms-of-service.html
Received on Tue Mar 31 06:30:36 2009

This archive was generated by hypermail 2.1.8 : Tue Mar 31 2009 - 06:30:37 PST