I regularly process tables using XSLT->FO.
This can seem more difficult than it is if you try to use XSLT as a sequential processing tool - which is when you get your illegal end-tag+start-tag problem.
A general approach - which would probably work in your case - is to use the declarative nature of XSLT and specify output you want based on the input structure.


This is sometimes speeded up by the use of keys - but these can impose a big overhead on large documents, often with a corresponding increase in processing time and memory.
So - in your case - if the document is small enough (a few Mb or so)
1. do a for-each loop on each <X/> element
2. within this get a list of the 1st <Y/> item of each value (using Muenchian generate-id trick)
2.1 - You may need to amend this to select only those <Y/> items where the preceding <X/> item is the same as the current one if the <Y/>s are not nested within <X>...</X>
3. do a for-each loop on these WITHIN enclosing table-row tags.
4. for each <Y/> value - get a list of all the following elements with the same value and do a for-each loop outputting each table-cell.


For large documents it can be more efficient to break this XSLT into multiple steps (ie separate transformations).
E.g. - group the <Y/>s within <X>..<X/> 1st if they are not grouped.
or tag the 1st and last() <Y/> items of a particular value with a tag indicating start table-row, end table-row
or add a ROW element grouping <Y/> items of same value.


The best approach is determined by the structure of the input data and what steps are necessary to turn it into an appropriate structure to produce your output.

For large volumes of tables I have found that an initial step breaking my input document into sub documents for each desired output table
and producing a table-of-contents master XML document containing references to the sub-documents to be used for the subsequent output processing is usually the most efficient approach.
This lets me process thousands of tables with the same overhead as for one table.



Jan Kohnert wrote:

Hi List,

I m trying to set up a table out of elements which are all almost the same.
There are only two indicators to determine to which position in the table a
element fits.
1. All elements with the same value in <X/> belong to one table. 2. All elements with the same value in <Y/> belong to one row.


Each element always belongs into the next cell following except it has an
different value in <Y/>. So when the value <Y> changes all following
elements shall be written into the next row until the value changes again.

I know that there are much smarter ways to set up rules for a table, but it
was not my decision...

The problem caused by this setup is, that i have to close and open a
<table-row/> while processing the XML data with a XSLT Stylesheet. But as we
all probably know is something like:

<xsl:if test"$NewValue = 'true'">
        </fo:table-row>
        <fo:table-row>
</xsl:if>

everything else than proper XML.

I wonder how I can change a table-row while processing data.

Does anybody has an Idea?

Thanks in advance!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- Datalucid Limited 8 Eileen Road South Norwood London SE25 5EJ / tel :0208-239-6810 mob: 0794-725-9760 email: [EMAIL PROTECTED] / UK Co. Reg: 4383635 VAT Reg.: 798 7531 60



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to