antonio.castellon Posted January 13, 2013 Share Posted January 13, 2013 (edited) 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 Edited January 13, 2013 by antonio.castellon Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now