hollybison
New Member
I'm having trouble to do arithmetic math and store somewhere. I have to create a rank that is based on the games. If a country win get 3 points and if it is a draw win 1 point.In the code there is 1 draw and 5 wins. How I sum the point from the countries?Do I need the element or I create an attribute or something else?XML:\[code\]<?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>\[/code\]xsl:\[code\]<?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>\[/code\]schema:\[code\]<?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="http://stackoverflow.com/questions/14544438/0"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="AT_7"> <xs:restriction base="xs:string"> <xs:enumeration value="http://stackoverflow.com/questions/14544438/A"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="AT_5"> <xs:restriction base="xs:int"> <xs:enumeration value="http://stackoverflow.com/questions/14544438/1"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/3"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/5"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/7"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="AT_3"> <xs:restriction base="xs:int"> <xs:enumeration value="http://stackoverflow.com/questions/14544438/0"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/1"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/2"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/4"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/6"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/8"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="AT_2"> <xs:restriction base="xs:string"> <xs:enumeration value="http://stackoverflow.com/questions/14544438/s1"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/s2"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/s3"/> <xs:enumeration value="http://stackoverflow.com/questions/14544438/s4"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="AT_1"> <xs:restriction base="xs:string"> <xs:enumeration vhttp://stackoverflow.com/questions/14544438/alue="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>\[/code\]