我在做算术数学和存储在某个地方时遇到了麻烦。我必须创建一个基于游戏的排名。如果国家队获胜得 3 分,如果是平局则得 1 分。
在代码中有 1 平和 5 胜。我如何总结各国的观点?我需要元素还是创建属性或其他东西?
XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="file:///C:/Users/Cesar%20Frantz/Desktop/teste.xsl"?>
<Bolaocopa xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/Users/Cesar%20Frantz/Desktop/teste.xsd">
<grupos>
<grupo tipo="A">
<pais id="s1">Franca<pontos>0</pontos></pais>
<pais id="s2">Senegal<pontos>0</pontos></pais>
<pais id="s3">Uruguai<pontos>0</pontos></pais>
<pais id="s4">Dinamarca<pontos>0</pontos></pais>
</grupo>
</grupos>
<jogoGrupo id="a">
<selecao paiscasa="s1" golc="1" paisfora="s2" golf="1"/>
<selecao paiscasa="s3" golc="2" paisfora="s4" golf="3"/>
<selecao paiscasa="s4" golc="4" paisfora="s2" golf="1"/>
<selecao paiscasa="s3" golc="6" paisfora="s1" golf="3"/>
<selecao paiscasa="s4" golc="8" paisfora="s1" golf="5"/>
<selecao paiscasa="s2" golc="1" paisfora="s3" golf="7"/>
</jogoGrupo>
</Bolaocopa>
xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="file:///C:/Users/Cesar%20Frantz/Desktop/teste.xsl"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/Bolaocopa">
<xsl:for-each select="/Bolaocopa/jogoGrupo[1]/selecao">
<xsl:variable name="paiscasa" select="@paiscasa" />
<xsl:variable name="paisfora" select="@paisfora" />
<xsl:variable name="contador"/>
<xsl:if test="(@golc > @golf)">
Vitoria::
<xsl:value-of select="/Bolaocopa/grupos/grupo/pais[@id = $paiscasa]"/>
<br/><br/>
</xsl:if>
<xsl:if test="(@golf > @golc)">
Vitoria::
<xsl:value-of select="/Bolaocopa/grupos/grupo/pais[@id = $paisfora]"/>
<br/><br/>
</xsl:if>
<xsl:if test="(@golf = @golc)">
Empate::
<xsl:value-of select="/Bolaocopa/grupos/grupo/pais[@id = $paiscasa]"/>
e <xsl:value-of select="/Bolaocopa/grupos/grupo/pais[@id = $paisfora]"/>
<br/><br/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
架构:
<?xml version="1.0" encoding="UTF-8"?>
<!--W3C Schema generated by XMLSpy v2013 sp1 (x64) (http://www.altova.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="T_pontos">
<xs:restriction base="xs:int">
<xs:enumeration value="0"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AT_7">
<xs:restriction base="xs:string">
<xs:enumeration value="A"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AT_5">
<xs:restriction base="xs:int">
<xs:enumeration value="1"/>
<xs:enumeration value="3"/>
<xs:enumeration value="5"/>
<xs:enumeration value="7"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AT_3">
<xs:restriction base="xs:int">
<xs:enumeration value="0"/>
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
<xs:enumeration value="4"/>
<xs:enumeration value="6"/>
<xs:enumeration value="8"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AT_2">
<xs:restriction base="xs:string">
<xs:enumeration value="s1"/>
<xs:enumeration value="s2"/>
<xs:enumeration value="s3"/>
<xs:enumeration value="s4"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AT_1">
<xs:restriction base="xs:string">
<xs:enumeration value="a"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="T_selecao">
<xs:attribute ref="paisfora" use="required"/>
<xs:attribute ref="paiscasa" use="required"/>
<xs:attribute ref="golf" use="required"/>
<xs:attribute ref="golc" use="required"/>
</xs:complexType>
<xs:complexType name="T_pais" mixed="true">
<xs:sequence>
<xs:element ref="pontos"/>
</xs:sequence>
<xs:attribute name="id" type="AT_2" use="required"/>
</xs:complexType>
<xs:complexType name="T_jogoGrupo">
<xs:sequence>
<xs:element ref="selecao" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="id" type="AT_1" use="required"/>
</xs:complexType>
<xs:complexType name="T_grupos">
<xs:sequence>
<xs:element ref="grupo"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="T_grupo">
<xs:sequence>
<xs:element ref="pais" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute ref="tipo" use="required"/>
</xs:complexType>
<xs:complexType name="T_Bolaocopa">
<xs:sequence>
<xs:element ref="grupos"/>
<xs:element ref="jogoGrupo"/>
</xs:sequence>
</xs:complexType>
<xs:attribute name="tipo" type="AT_7"/>
<xs:attribute name="paisfora" type="AT_2"/>
<xs:attribute name="paiscasa" type="AT_2"/>
<xs:attribute name="golf" type="AT_5"/>
<xs:attribute name="golc" type="AT_3"/>
<xs:element name="selecao" type="T_selecao"/>
<xs:element name="pontos" type="T_pontos"/>
<xs:element name="pais" type="T_pais"/>
<xs:element name="jogoGrupo" type="T_jogoGrupo"/>
<xs:element name="grupos" type="T_grupos"/>
<xs:element name="grupo" type="T_grupo"/>
<xs:element name="Bolaocopa" type="T_Bolaocopa"/>
</xs:schema>