-- 作者:jj_long
-- 发布时间:5/27/2010 11:59:00 PM
--
看一下能否解决你的问题: XSLT: ============================================ <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes"/> <xsl:variable name="v_footyresult" select="document('footyresult.xml')"></xsl:variable> <xsl:template match="/"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Score</title> <style type="text/css"> body{ font-family:Arial, Helvetica, sans-serif; font-size:9px; } table{ font-family:Arial, Helvetica, sans-serif; font-size:99x; } </style> </head> <body> <table border="1" width="90%" align="center"> <caption>Score</caption> <tr> <th>name</th> <th>headCoach</th> <th>goal</th> <th>behind</th> </tr> <xsl:apply-templates/> </table> </body> </html> </xsl:template> <xsl:template match="team"> <xsl:variable name="v_name" select="name"/> <tr> <td><xsl:value-of select="$v_name"/></td> <td><xsl:value-of select="headCoach"/></td> <td><xsl:value-of select="$v_footyresult/season/round/match/team[name=$v_name]/score/goal"/></td> <td><xsl:value-of select="$v_footyresult/season/round/match/team[name=$v_name]/score/behind"/></td> </tr> </xsl:template> </xsl:stylesheet> ============================================= 输出结果: ============================================= <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Score</title><style type="text/css"> body{ font-family:Arial, Helvetica, sans-serif; font-size:9px; } table{ font-family:Arial, Helvetica, sans-serif; font-size:99x; } </style></head> <body> <table border="1" width="90%" align="center"> <caption>Score</caption> <tr> <th>name</th> <th>headCoach</th> <th>goal</th> <th>behind</th> </tr> <tr> <td>Brisbane Lions</td> <td>L.Matthews</td> <td>9</td> <td>15</td> </tr> <tr> <td>Carlton Blues</td> <td>D.Pagan</td> <td>15</td> <td>25</td> </tr> <tr> <td>Collingwood Magpies</td> <td>M.Malthouse</td> <td>12</td> <td>10</td> </tr> <tr> <td>Essendon Bombers</td> <td>K.Sheedy</td> <td>16</td> <td>9</td> </tr> <tr> <td>Fremantle Dockers</td> <td>C.Connolly</td> <td>16</td> <td>0</td> </tr> <tr> <td>Geelong Cats</td> <td>M.Thompson</td> <td>13</td> <td>15</td> </tr> <tr> <td>Hawthorn Hawks</td> <td>A.Clarkson</td> <td>6</td> <td>8</td> </tr> <tr> <td>Melbourne Demons</td> <td>N.Danniher</td> <td>9</td> <td>8</td> </tr> <tr> <td>North Melbourne Kangaroos</td> <td>D.Laidley</td> <td>10</td> <td>19</td> </tr> <tr> <td>Port Adelaide Powers</td> <td>M.Williams</td> <td>19</td> <td>7</td> </tr> <tr> <td>Richmond Tigers</td> <td>T.Wallace</td> <td>15</td> <td>8</td> </tr> <tr> <td>Saint Kilda Saints</td> <td>G.Thomas</td> <td>13</td> <td>15</td> </tr> <tr> <td>Sydney Swans</td> <td>P.Roos</td> <td>10</td> <td>13</td> </tr> <tr> <td>West Coast Eagles</td> <td>J.Worsfold</td> <td>11</td> <td>8</td> </tr> <tr> <td>Western Bulldogs</td> <td>R.Eade</td> <td>17</td> <td>11</td> </tr> <tr> <td>Adelaide Crows</td> <td>N.Craig</td> <td>10</td> <td>14</td> </tr> </table> </body> </html> ============================================= 注:我使用了Saxon 6.5.5调试此程序。
|