2013-04-26 5 views
1

축구 리그 용 순위판을 만들려고합니다. 나는 XSLT에 익숙하지 않았고 내 실수를 저지르고있다.XSLT 후속 형제가 값을 반환하지 않음

<sports-statistics> 
    <sports-team-stats> 
    <date year="2013" month="4" date="23" day="2"/> 
    <time hour="16" minute="00" second="59" timezone="Eastern" utc-hour="-4" utc-minute="00"/> 
    <version number="2"/> 
    <league global-id="513" name="Youth Soccer League" alias="YSL" display-name=""/> 
    <season year="2013" id="1" description="2013 YSL Season"/> 
    <soccer-ifb-team-stats> 
     <ifb-team> 
     <team-info global-id="11270" id="1869" location="Tulsa" name="Astecs" alias="TUL" display-name="Astecs"/> 
     <split id="0" type="all" name="All Games"> 
      <games-played games="1"/> 
      <record wins="0" losses="0" ties="1" percentage=".500"/> 
      <minutes minutes="90"/> 
      <goals goals="1" headed="0" kicked="1" /> 
      <opponent-goals goals="1"/> 
      <own-goals goals="0"/> 
      <assists assists="1"/> 
      <opponent-assists assists="1"/> 
      <shots shots="18"/> 
      <opponent-shots shots="10"/> 
      <shots-on-goal shots="7"/> 
      <opponent-shots-on-goal shots="4"/> 
     </split> 
     <split id="302" type="home" name="Home Games"> 
      <games-played games="1"/> 
      <record wins="0" losses="0" ties="1" percentage=".500"/> 
      <minutes minutes="90"/> 
      <goals goals="1" headed="0" kicked="1" /> 
      <opponent-goals goals="1"/> 
      <own-goals goals="0"/> 
      <assists assists="1"/> 
      <opponent-assists assists="1"/> 
      <shots shots="18"/> 
      <opponent-shots shots="10"/> 
      <shots-on-goal shots="7"/> 
      <opponent-shots-on-goal shots="4"/> 
     </split> 
     </ifb-team> 
    </soccer-ifb-team-stats> 
    </sports-team-stats> 
</sports-statistics> 

여기에 지금까지 내 코드입니다 :

다음은 내가

데이터가 그 데이터 형식입니다.

<?xml version="1.0" encoding="iso-8859-1"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" 
> 
    <xsl:output method="html" indent="yes" encoding = "utf-8" standalone = "yes"/> 

    <xsl:variable name="allGames"> 
    <map gametype="All Games" /> 
    </xsl:variable> 
    <xsl:variable name="gameMapping" select="msxsl:node-set($allGames)/*" /> 

    <xsl:template match="/"> 

    <html> 
     <head> 
     <meta charset="utf-8" /> 
     <title> Standings</title> 
     </head> 

     <body> 
     <h2> TEST </h2> 

     <table border="1" style="width: 100%;"> 
      <tr> 
      <th>Club</th>   
      <th>GP</th> <!--Games Played--> 
      <th>W</th> <!--Wins--> 
      <th>L</th> <!--Loss--> 
      <th>T</th> <!--Ties--> 
      <th>%</th> <!--Win Loss Ratio--> 
      </tr> 

      <xsl:apply-templates select="//ifb-team/split[@name = 'All Games']" /> 

     </table> 
     </body> 
    </html> 
    </xsl:template> 

    <xsl:template match="ifb-team/split"> 
    <xsl:variable name="ti" select="../team-info" /> 
    <tr> 
     <td> 
     <xsl:value-of select="$ti/@display-name" /> 
     </td> 
     <td> 
     <xsl:value-of select="following-sibling::games-played/@games"/> 
     </td> 
     <td> 
     <xsl:value-of select="following-sibling::record/@wins"/> 
     </td> 
     <td> 
     <xsl:value-of select="following-sibling::record/@losses"/> 
     </td> 
     <td> 
     <xsl:value-of select="following-sibling::record/@ties"/> 
     </td> 
     <td> 
     <xsl:value-of select="following-sibling::record/@percentage"/> 
     </td> 
    </tr> 
    </xsl:template> 

</xsl:stylesheet> 

내가보기에 표시 이름 만있는 테이블이 있습니다. 나는 형제 데이터를 얻지 못하고있다. 내가 뭘 놓치고 있니?

답변

1

간단하다 :

games-played는 형제 아니다 - 그것은 아이 split입니다.

record에 대해서도 마찬가지입니다.

따라서,를 사용

<td> 
    <xsl:value-of select="games-played/@games"/> 
    </td> 
    <td> 
    <xsl:value-of select="record/@wins"/> 
    </td> 
    <td> 
    <xsl:value-of select="record/@losses"/> 
    </td> 
    <td> 
    <xsl:value-of select="record/@ties"/> 
    </td> 
    <td> 
    <xsl:value-of select="record/@percentage"/> 
    </td> 
+0

OMG가 .... 감사 내가 XPath는 다시 가서 좀 더 공부해야 할 것 같아요! –

+0

@KurtAbele, 확실히 - XPath는 XSLT와 XQuery의 핵심입니다. –

관련 문제