[xsl] Alternatives to "Stopping" a for-each

Subject: [xsl] Alternatives to "Stopping" a for-each
From: <trond.huso@xxxxxx>
Date: Thu, 14 Feb 2013 13:10:02 +0000
I have to create the following list based on xml-structure below. It is a list
of ranked horses, and where the last number (if there are more than one
number) is the winning horse.

Rangering: 1. avd: 7-11-6-12 (str. 4), 2. avd: 9 (str. 1), 3. avd: 8, 4. avd:
4-8 (str. 5), 5. avd: 6 (str. 10).

The example uses the bold part of the text.

So the idea is that I am sorting the ranking, looping the structure. When I
hit the winning horse, I shall stop the loop.
Now I know that you cannot stop a for-each in xslt, so what is the best way to
this then?



<Start>
                            <StartNo>1</StartNo>
                            <Horse>
                                <RegNo>N-04-0514</RegNo>
                                <Name>Rise Stjerna</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>8279</LicenseNo>
                                <FirstName>Kristine</FirstName>
                                <LastName>Kvasnes</LastName>
                            </Driver>
                            <Distance>2140</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>9</Ranking>
                        </Start>
                        <Start>
                            <StartNo>2</StartNo>
                            <Horse>
                                <RegNo>N-07-0133</RegNo>
                                <Name>Bovis Rambo</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>79</LicenseNo>
                                <FirstName>Thor</FirstName>
                                <LastName>Borg</LastName>
                            </Driver>
                            <Distance>2140</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>6</Ranking>
                        </Start>
                        <Start>
                            <StartNo>3</StartNo>
                            <Horse>
                                <RegNo>N-02-0165 </RegNo>
                                <Name>Edne Kongen</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>2014063</LicenseNo>
                                <FirstName>Oda</FirstName>
                                <LastName>Verdal</LastName>
                            </Driver>
                            <Distance>2140</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>11</Ranking>
                        </Start>
                        <Start>
                            <StartNo>4</StartNo>
                            <Horse>
                                <RegNo>S-08-0191</RegNo>
                                <Name>Jfrvsx Kristina</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>17044</LicenseNo>
                                <FirstName>Xystein</FirstName>
                                <LastName>Tjomsland</LastName>
                            </Driver>
                            <Distance>2160</Distance>
                            <Scratched>true</Scratched>
                            <Ranking>0</Ranking>
                        </Start>
                        <Start>
                            <StartNo>5</StartNo>
                            <Horse>
                                <RegNo>N-07-0107</RegNo>
                                <Name>Magnums Amadeus</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>5697</LicenseNo>
                                <FirstName>Arild</FirstName>
                                <LastName>Beres</LastName>
                            </Driver>
                            <Distance>2160</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>5</Ranking>
                        </Start>
                        <Start>
                            <StartNo>6</StartNo>
                            <Horse>
                                <RegNo>578001020080549</RegNo>
                                <Name>Willblesen</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>30399</LicenseNo>
                                <FirstName>Rudolf</FirstName>
                                <LastName>Roland</LastName>
                            </Driver>
                            <Distance>2160</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>3</Ranking>
                        </Start>
                        <Start>
                            <StartNo>7</StartNo>
                            <Horse>
                                <RegNo>N-05-0660</RegNo>
                                <Name>Lill Ronja</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>1537</LicenseNo>
                                <FirstName>Eirik</FirstName>
                                <LastName>Hxitomt</LastName>
                            </Driver>
                            <Distance>2160</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>1</Ranking>
                        </Start>
                        <Start>
                            <StartNo>8</StartNo>
                            <Horse>
                                <RegNo>N-04-0365</RegNo>
                                <Name>Per Even</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>65285</LicenseNo>
                                <FirstName>Vidar</FirstName>
                                <LastName>Tjomsland</LastName>
                            </Driver>
                            <Distance>2160</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>7</Ranking>
                        </Start>
                        <Start>
                            <StartNo>9</StartNo>
                            <Horse>
                                <RegNo>N-05-0179</RegNo>
                                <Name>Es Glimten</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>5040</LicenseNo>
                                <FirstName>Johan Herbjxrn</FirstName>
                                <LastName>Undem</LastName>
                            </Driver>
                            <Distance>2160</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>10</Ranking>
                        </Start>
                        <Start>
                            <StartNo>10</StartNo>
                            <Horse>
                                <RegNo>N-06-0047</RegNo>
                                <Name>Pola Linus</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>2127</LicenseNo>
                                <FirstName>Kristian</FirstName>
                                <LastName>Malmin</LastName>
                            </Driver>
                            <Distance>2180</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>8</Ranking>
                        </Start>
                        <Start>
                            <StartNo>11</StartNo>
                            <Horse>
                                <RegNo>N-03-0261</RegNo>
                                <Name>Odintroll</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>8345</LicenseNo>
                                <FirstName>Ole Johan</FirstName>
                                <LastName>Xstre</LastName>
                            </Driver>
                            <Distance>2180</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>2</Ranking>
                        </Start>
                        <Start>
                            <StartNo>12</StartNo>
                            <Horse>
                                <RegNo>N-07-0209</RegNo>
                                <Name>Tallas</Name>
                            </Horse>
                            <Driver>
                                <LicenseNo>5740</LicenseNo>
                                <FirstName>Jan Rune</FirstName>
                                <LastName>Gaustad</LastName>
                            </Driver>
                            <Distance>2180</Distance>
                            <Scratched>false</Scratched>
                            <Ranking>4</Ranking>
                        </Start>


Best regards,

Trond Husx
System Developer
www.ntb.no

Current Thread