[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Simple problem - complicated solution

Subject: Re: Simple problem - complicated solution
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 16 May 2002 19:25:33 +0200
Re:  Simple problem - complicated solution
<xsl:template match="data">
<!-- selects the first datum/@value with not a following datum/@value less than this one -->
<min value="{datum[not(../datum/@value &lt; @value)]/@value}"/>
<!-- selects the first datum/@value with not a following datum/@value greater than this one -->
<max value="{datum[not(../datum/@value > @value)]/@value}"/>
<!-- like in mathematics: avg = sum / count -->
<avg value="{sum(datum/@value)/count(datum/@value)}"/>
</xsl:template>


Regards,

Joerg

Antonio Fiol schrieb:
Hello, I have an XML document that contains:

<data>
<datum value="123"/>
<datum value="234"/>
<datum value="99"/>
<!-- Some more data... -->
</data>

I wish to use a XSLT document to output:

<data>
<min value="99" />
<max value="234" />
<avg value="..." />
</data>

This does not seem too complicated, but I cannot figure how to do it.

I do not mind if I have to rewrite my question in terms of:

<datum>123</datum>

and my answer as:

<min>99</min>

Thank you very much in advance.

Antonio Fiol


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.