Hallo Wissende,
ich habe unten den teilweisen Inhalt einer XML-Datei und der dazugehördenen XSL-Datei angehangen. Mir ist klar, dass die XSL nicht perfekt ist und optimiert werden muss. Leider weiss ich nicht wie. In der XML-Datei stehen Spiele auf verschiedenen Plätzen.
Als Ergebnis sollen alle Spiele jedes Platzes angezeigt werden, ohne dass in der XSL statisch drin steht, welcher Platz es ist. Also wenn zu Beginn eines Turiniers auf 4 Plätzen gespielt wird, sollen 4 Tabellen erzeugt werden, in denen die Spiele des Platzes stehen, egal wie der Platz heisst. Bei jedem Spiel steht in der XML eine CourtId, die den Namen des Spielplatzes ausmacht.
Wie kann ich es als anders/besser in der XSL lösen?
XML-Inhalt: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="matches.xsl" ?> <?xml-stylesheet type="text/css" href="index.css" ?> <glossar> <eintrag> <DateSeq>3</DateSeq> <MatchNo>10</MatchNo> <NumSets>3</NumSets> <Player1>Gabashvili Teimuraz</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Guez David</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId>Zaloga Gabriela</OfficialId> <CourtId>2</CourtId> <Winner>1</Winner> <LongScore>3/6 6/1 6/2</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>11</MatchNo> <NumSets>3</NumSets> <Player1>Luzzi Federico</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Galvani Stefano</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId>Dumusois Damien</OfficialId> <CourtId>2</CourtId> <Winner>1</Winner> <LongScore>6/3 4/6 6/2</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>12</MatchNo> <NumSets>3</NumSets> <Player1>Portas Albert</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Falla Alejandro</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId>Stellabotte Nicholas</OfficialId> <CourtId>3</CourtId> <Winner>1</Winner> <LongScore>6/4 6/7(6/8) 6/3</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>13</MatchNo> <NumSets>3</NumSets> <Player1>Roitman Sergio</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Kunitsyn Igor</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId></OfficialId> <CourtId>3</CourtId> <Winner>1</Winner> <LongScore>6/3 6/3</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>14</MatchNo> <NumSets>3</NumSets> <Player1>Haehnel Jerome</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Pavel Andrei</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId>Thiemann Michael</OfficialId> <CourtId>2</CourtId> <Winner>2</Winner> <LongScore>6/3 7/6(7/2)</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>17</MatchNo> <NumSets>3</NumSets> <Player1>Djokovic Novak</Player1> <Player1a>Verdasco Fernando</Player1a> <Player2>Acasuso Jose</Player2> <Player2a>Chela Juan Ignacio</Player2a> <OfficialId>Mourier Cedric</OfficialId> <CourtId>3</CourtId> <Winner>2</Winner> <LongScore>7/6(7/4) 6/1</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>34</MatchNo> <NumSets>3</NumSets> <Player1>Lee Hyung-Taik</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Bjorkman Jonas</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId>Dercq Jean-Philippe</OfficialId> <CourtId>2</CourtId> <Winner>1</Winner> <LongScore>7/6(8/6) 6/1</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>37</MatchNo> <NumSets>3</NumSets> <Player1>Balleret Benjamin</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Benneteau Julien</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId></OfficialId> <CourtId>1</CourtId> <Winner>2</Winner> <LongScore>7/5 5/7 6/2</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>49</MatchNo> <NumSets>3</NumSets> <Player1>Clement Arnaud</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Serra Florent</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId>Maria Pascal</OfficialId> <CourtId>1</CourtId> <Winner>1</Winner> <LongScore>6/4 7/6(7/5)</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>60</MatchNo> <NumSets>3</NumSets> <Player1>Nieminen Jarkko</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Safin Marat</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId></OfficialId> <CourtId>1</CourtId> <Winner>2</Winner> <LongScore>5/7 6/3 6/2</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>8</MatchNo> <NumSets>3</NumSets> <Player1>Kohlschreiber Philipp</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Bozoljac Ilia</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId></OfficialId> <CourtId>3</CourtId> <Winner>1</Winner> <LongScore>6/1 6/4</LongScore> </eintrag> <eintrag> <DateSeq>3</DateSeq> <MatchNo>9</MatchNo> <NumSets>3</NumSets> <Player1>Garcia-Lopez Guillermo</Player1> <Player1a>00000000-0000-0000-ffff-000000000000</Player1a> <Player2>Seppi Andreas</Player2> <Player2a>00000000-0000-0000-ffff-000000000000</Player2a> <OfficialId>Gabas Arnaud</OfficialId> <CourtId>1</CourtId> <Winner>2</Winner> <LongScore>6/3 6/3</LongScore> </eintrag> </glossar>
XSL-Inhalt: <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/"> <html> <head> <link rel="stylesheet" href="index.css" type="text/css" /> </head>
<body onselectstart="return false" onDragStart="return false" onDrop="return false">
<table class="match" cellpadding="0" cellspacing="0" align="center" width="100%"> <tr><th colspan="4">Court 1</th></tr> <tr> <th class="small">No.</th> <th class="small">Player A</th> <th class="small">Player B</th> <th class="small">Result</th> </tr> <xsl:for-each select="glossar/eintrag"> <xsl:if test="CourtId='1'"> <tr> <td width="5%" valign="top"><xsl:value-of select="MatchNo" /></td> <td width="35%" valign="top"><xsl:value-of select="Player1" /></td> <td width="35%" valign="top"><xsl:value-of select="Player2" /></td> <td width="25%" valign="top"><xsl:value-of select="LongScore" /></td> </tr> </xsl:if> </xsl:for-each> </table>
<table class="match" cellpadding="0" cellspacing="0" align="center" width="100%"> <tr><th colspan="4">Court 2</th></tr> <tr> <th class="small">No.</th> <th class="small">Player A</th> <th class="small">Player B</th> <th class="small">Result</th> </tr> <xsl:for-each select="glossar/eintrag"> <xsl:if test="CourtId='2'"> <tr> <td width="5%" valign="top"><xsl:value-of select="MatchNo" /></td> <td width="35%" valign="top"><xsl:value-of select="Player1" /></td> <td width="35%" valign="top"><xsl:value-of select="Player2" /></td> <td width="25%" valign="top"><xsl:value-of select="LongScore" /></td> </tr> </xsl:if> </xsl:for-each> </table>
<table class="match" cellpadding="0" cellspacing="0" align="center" width="100%"> <tr><th colspan="4">Court 3</th></tr> <tr> <th class="small">No.</th> <th class="small">Player A</th> <th class="small">Player B</th> <th class="small">Result</th> </tr> <xsl:for-each select="glossar/eintrag"> <xsl:if test="CourtId='3'"> <tr> <td width="5%" valign="top"><xsl:value-of select="MatchNo" /></td> <td width="35%" valign="top"><xsl:value-of select="Player1" /></td> <td width="35%" valign="top"><xsl:value-of select="Player2" /></td> <td width="25%" valign="top"><xsl:value-of select="LongScore" /></td> </tr> </xsl:if> </xsl:for-each> </table>
<table class="match" cellpadding="0" cellspacing="0" align="center" width="100%"> <tr><th colspan="4">Court 4</th></tr> <tr> <th class="small">No.</th> <th class="small">Player A</th> <th class="small">Player B</th> <th class="small">Result</th> </tr> <xsl:for-each select="glossar/eintrag"> <xsl:if test="CourtId='4'"> <tr> <td width="5%" valign="top"><xsl:value-of select="MatchNo" /></td> <td width="35%" valign="top"><xsl:value-of select="Player1" /></td> <td width="35%" valign="top"><xsl:value-of select="Player2" /></td> <td width="25%" valign="top"><xsl:value-of select="LongScore" /></td> </tr> </xsl:if> </xsl:for-each> </table>
<h3>Court 5</h3> <table class="match" cellpadding="0" cellspacing="0" align="center" width="100%"> <tr> <th class="small">No.</th> <th class="small">Player A</th> <th class="small">Player B</th> <th class="small">Result</th> </tr> <xsl:for-each select="glossar/eintrag"> <xsl:if test="CourtId='5'"> <tr> <td width="5%" valign="top"><xsl:value-of select="MatchNo" /></td> <td width="35%" valign="top"><xsl:value-of select="Player1" /></td> <td width="35%" valign="top"><xsl:value-of select="Player2" /></td> <td width="25%" valign="top"><xsl:value-of select="LongScore" /></td> </tr> </xsl:if> </xsl:for-each> </table>
</body> </html> </xsl:template>
</xsl:stylesheet>