Jump to content

antonio.castellon

Members
  • Posts

    1
  • Joined

  • Last visited

antonio.castellon's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hi developers, I have a problem when I try to order an XML data, I spent more than 6 hours with different XSLT combinations and I can't find a solution. :-( it's see stupid and simple thing, but I don't know what is wrong in my code (and konwledge) about xsl:sort,the idea is to sort by the two nodes children's sum , but I can't do it with sum , without sum , ... Please, anybody could help me ? <?xml version="1.0" encoding="UTF-8"?><root> <match> <team1><name>A</name></team1> <team2><name>C</name></team2> <scores> <score> <team1>0</team1> <team2>0</team2> </score> </scores> </match><match> <team1><name>B</name></team1> <team2><name>B</name></team2> <scores> <score> <team1>1</team1> <team2>1</team2> </score> </scores> </match><match> <team1><name>C</name></team1> <team2><name>A</name></team2> <scores> <score> <team1>2</team1> <team2>2</team2> </score> </scores> </match></root> I use this next xslt code ... <?xml version="1.0" encoding="utf-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"><xsl:output method="text" omit-xml-declaration="yes" indent="no" version="1.0" encoding="UTF-8"/> <xsl:template match="root"> <xsl:for-each select="match"><!-- this sort HERE is OK ...but it is not the solution that I wanted<xsl:sort select="team1/name" order="descending" />--><xsl:for-each select="scores/score/team1"><!-- this is the sort with strange problem , I want to order by the values in the deeper childrens --><xsl:sort select="." order="descending" />[<xsl:value-of select="sum(../*)" />] <xsl:value-of select="." /> - <xsl:value-of select="../../../team1/name" /> </xsl:for-each> </xsl:for-each>.</xsl:template></xsl:stylesheet> Thanks in advance ¡¡¡¡ toni
×
×
  • Create New...