【发布时间】:2018-08-04 15:29:17
【问题描述】:
我正在使用 XSLT 来显示游戏列表。每个游戏根据其在数据库中的位置 (y="{($position)*10}%") 进行定位。我的问题是,当数据库中有太多游戏时,这些游戏不会显示。我也尝试使用 with overflow="scroll" 但这没有用。如何在数据库增长时也显示我的输出,以便我可以滚动查看所有游戏?
<xsl:template match="/">
<svg height="100%" width="100%" xmlns="http://www.w3.org/2000/svg" overflow="scroll">
<xsl:for-each select="//game">
<xsl:variable name="gameid" select="@gameid"/>
<xsl:variable name="name1" select="players/player[@id='1']/name"/>
<xsl:variable name="name2" select="players/player[@id='2']/name"/>
<xsl:variable name="points1" select="players/player[@id='1']/points"/>
<xsl:variable name="points2" select="players/player[@id='2']/points"/>
<xsl:variable name="position" select="position()"/>
<text x="10%" y="{($position)*10}%" font-family="Verdana" font-size="100%">Id:</text>
<text x="18%" y="{($position)*10}%" font-family="Verdana" font-size="100%" ><xsl:value-of select="$gameid"/></text>
<text x="25%" y="{($position)*10}%" font-family="Verdana" font-size="100%"><xsl:value-of select="$name1"/>(<xsl:value-of select="$points1"/>) vs. <xsl:value-of select="$name2"/>(<xsl:value-of select="$points2"/>)</text>
</xsl:for-each>
</svg>
</xsl:template>
这里是xml文件的一部分。在数据库中,这个 xml 文件多次包含不同的值。
<game gameid="2018-02-24T20:31:49.058>
<players>
<player id="1" playing="true">
<name></name>
<points>0</points>
</player>
<player id="2" playing="false">
<name>awd</name>
<points>0</points>
</player>
</players>
</game>
【问题讨论】:
-
发布 XML 的 sn-p 以完成 minimal reproducible example 将有助于发现问题。
-
好的,谢谢,我编辑了。希望有帮助!
标签: xml xslt svg overflow basex