You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Jan Kohnert <J....@swisslab.de> on 2004/03/25 14:35:23 UTC

Building a matrix (table) out of almost equal elements

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: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: Building a matrix (table) out of almost equal elements

Posted by Clay Leeds <cl...@medata.com>.
Jan,

On Mar 25, 2004, at 5:35 AM, Jan Kohnert wrote:
> I wonder how I can change a table-row while processing data.
>
> Does anybody has an Idea?
>
> Thanks in advance!

This question is more appropriate for the XSLT Mulberry list[1]. When 
you ask, you probably want to include a portion of the XML itself, as 
that will help others understand how to build the XPath you need. I 
suspect you'll have to either use xsl:variable, or perhaps 
xsl:call-template. 'keys' may be another avenue to try.

Good luck!

Web Maestro Clay

[1]
http://xml.apache.org/fop/maillist.html



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: Building a matrix (table) out of almost equal elements

Posted by Mike Trotman <mi...@datalucid.com>.
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: fop-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: fop-user-help@xml.apache.org
>  
>

-- 
Datalucid Limited
8 Eileen Road
South Norwood
London SE25 5EJ
/ tel :0208-239-6810
mob: 0794-725-9760
email: mike.trotman@datalucid.com
/
UK Co. Reg:   	4383635
VAT Reg.:   	798 7531 60



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org