XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
giancarlo rossiSubject: group by min value
Author: giancarlo rossi
Date: 30 Oct 2006 10:03 AM
I dont understand becouse thes xsl not is able to group by min...

It doesnt display the min value of <supplier>po2</supplier>

see the attachement.
Thanks in advance.


Unknownitem.xsl


Unknownitem(1).xml

Postnext
Ivan PedruzziSubject: group by min value
Author: Ivan Pedruzzi
Date: 30 Oct 2006 10:49 PM

Because the loop is sorted ascending you need to consider only the first iteration.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="GROUP" match="item" use="supplier"/>
<xsl:template match="/">
<xsl:for-each select="root/item[generate-id(.)=generate-id(key('GROUP',supplier))]">
<xsl:sort select="totale_finale" data-type="number" order="ascending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="concat(supplier,' ', totale_finale) "/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Postnext
giancarlo rossiSubject: group by min value
Author: giancarlo rossi
Date: 31 Oct 2006 04:04 AM
Originally Posted: 31 Oct 2006 04:02 AM
HI Ivan,

In this case I get only one item

and the response is "po2 110"

not "po2 90"


further the results should be like this one:

pos2 90

pos3 222

pos1 2345


group by min and supplier...

Thanks in advance
Giancarlo.

Postnext
Ivan PedruzziSubject: group by min value
Author: Ivan Pedruzzi
Date: 31 Oct 2006 06:03 PM

Sorry Giancarlo I misunderstood you

The following does what you have described

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="GROUP" match="item" use="supplier"/>
<xsl:template match="/">
<xsl:for-each select="root/item[generate-id(.)=generate-id(key('GROUP',supplier))]">
<xsl:for-each select="key('GROUP',supplier)">
<xsl:sort select="totale_finale" data-type="number" order="ascending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="concat(supplier,' ', totale_finale, '&#xA;') "/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Posttop
giancarlo rossiSubject: group by min value
Author: giancarlo rossi
Date: 05 Nov 2006 04:47 AM
sorry for the delay...

just a little sort modification

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="GROUP" match="item" use="supplier"/>
<xsl:template match="/">
<xsl:for-each select="root/item[generate-id(.)=generate-id(key('GROUP',supplier))]">
<xsl:sort select="totale_finale" data-type="number" order="ascending"/>
<xsl:for-each select="key('GROUP',supplier)">
<xsl:if test="position() = 1">
<xsl:value-of select="concat(supplier,' ', totale_finale, '&#xA;') "/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Thanks a lot.
G.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.