Interesting Algorithmic problem with table need help - would be super nice

Tamer Demirel <[email protected]> Mon, 30 Nov 2009 12:25:52 +0100
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------030309000405090800090109
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

first i have to explain a lot sorry. I hope somebody can help me.
i am using Xalan 2.7.1 and exslt func:function and XSLT 1.0. Thats a 
problem too I know.

I have tables and they look like this. I already cut out the header and 
sort @top - @left

A B C D
x  x  x  x
---------
x  x  x  x

A B C D
x
--------
x  x     x

A B C D
x  x  x x
x
--------

What i know and what i have:
1. The Elements in column B (2.4, 7.6, 2.4, 2.4, 7.6) are required. They 
signal a new line. But if there is no Element then you have to concat 
the elements in the row with the elements in the row before. Could be 
the row in the other page too. Pagenumer 1 and 2. The ----- shows a new line
2. I know the ranges of the columns lefts: a from 75 to 364, b from 356 
to 586, c from 578 to 821 and d from 813 to 1134

My Algorithm:

--> Initialize variable minTopBefore = 0 --> global variable
1. Get minTop coordinate that is bigger then minTopBefore
--> Is it greater then minTopBefore?
NO? then finish
YES? then overwrite the variable minTopBefore with the value 
minTopBefore := minTop
and check this:
--> Do required Element exists in column B?
YES? Then get all the elements in the row like this 
<row1><a>x</a><b>x</b><c>x</c><d>x</d></row1>
NO? Then concat the element in the row the element above in row before 
like this <row1><a>x + concat(x)</a><b>x</b><c>x</c><d>x</d></row1>
Loop to 1.

Why i wanted it so?
My worther tables have two informations in one row. That is a big 
problem. But every row has a required Element. So i can always check in 
which line i am and get the elements in the row.
Do somebody have a better idea?

I could first extract the elements in lines?
Get first top of required Element and the second top of required 
Element. Everything between it except second top must be a line.
That could help me too i think. Then i could do another algorithm for 
all lines:

It would be super nice, if somebody can help me. I usually use Java and 
there i have not that big problems with variables.

THX VERY VERY MUCH,
Tamer

<printjob>
<page number="1">
        <TAX_ITEM>
            <text left="234" top="2678" width="125" 
height="46">1373.00</text>
            <text left="526" top="2678" width="57" height="46">2.4</text>
            <text left="738" top="2678" width="80" height="46">81.96</text>
            <text left="1007" top="2678" width="125" 
height="46">1381.96</text>
            <text left="234" top="2737" width="125" 
height="46">1108.00</text>
            <text left="526" top="2737" width="57" height="46">7.6</text>
            <text left="738" top="2737" width="80" height="46">8.21</text>
            <text left="1007" top="2737" width="125" 
height="46">116.21</text>
        </TAX_ITEM>
</page>
<page number="2">
        <TAX_ITEM>
            <text left="234" top="2678" width="125" height="46">test</text>
            <text left="234" top="2737" width="125" 
height="46">1108.00</text>
            <text left="526" top="2737" width="57" height="46">7.6</text>
            <text left="1007" top="2737" width="125" 
height="46">116.21</text>
        </TAX_ITEM>
</page>
<page number="3">
        <TAX_ITEM>
            <text left="234" top="2678" width="125" 
height="46">1373.00</text>
            <text left="526" top="2678" width="57" height="46">2.4</text>
            <text left="738" top="2678" width="80" height="46">81.96</text>
            <text left="1007" top="2678" width="125" 
height="46">1381.96</text>
            <text left="234" top="2778" width="125" height="46">test</text>
        </TAX_ITEM>
</page>
</printjob>


--------------030309000405090800090109
Content-Type: text/xml;
 name="text.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="text.xml"

<printjob>
	<page number="1">
		<TAX_ITEM>
			<text left="234" top="2678" width="125" height="46">1373.00</text>
			<text left="526" top="2678" width="57" height="46">2.4</text>
			<text left="738" top="2678" width="80" height="46">81.96</text>
			<text left="1007" top="2678" width="125" height="46">1381.96</text>
			<text left="234" top="2737" width="125" height="46">1108.00</text>
			<text left="526" top="2737" width="57" height="46">7.6</text>
			<text left="738" top="2737" width="80" height="46">8.21</text>
			<text left="1007" top="2737" width="125" height="46">116.21</text>
		</TAX_ITEM>
	</page>
	<page number="2">
		<TAX_ITEM>
			<text left="234" top="2678" width="125" height="46">test</text>
			<text left="234" top="2737" width="125" height="46">1108.00</text>
			<text left="526" top="2737" width="57" height="46">7.6</text>
			<text left="1007" top="2737" width="125" height="46">116.21</text>
		</TAX_ITEM>
	</page>
	<page number="3">
		<TAX_ITEM>
			<text left="234" top="2678" width="125" height="46">1373.00</text>
			<text left="526" top="2678" width="57" height="46">2.4</text>
			<text left="738" top="2678" width="80" height="46">81.96</text>
			<text left="1007" top="2678" width="125" height="46">1381.96</text>
			<text left="234" top="2778" width="125" height="46">test</text>
		</TAX_ITEM>
	</page>
</printjob>

--------------030309000405090800090109
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
exslt mailing list
[email protected]
http://www.exslt.org/list
--------------030309000405090800090109--