Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 17th, 2006, 08:57 PM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with XSL

i am putting together some payroll information for a sports team, and i'm using xml/xsl 1.0 to store/output the data.

i've managed to do some of the things i wanted, but there is something that i just can't figure out how to do.

i was wondering if someone could help me out with adding up all the values from the "CAP HIT" column. i mean, i can do it node by node, but i want something more flexible, or automatic for lack of a better word. is it even possible with XSLT? btw, the actual value is supposed to be $40,333,157.

in short... the way i calculated the CAP HIT was:
CAP HIT = (salary1 + salary2 + salary3 + ... + salary(n)) / (n)

what i want to do with that value now (but don't know how) is:
Total CAP HIT = (CAP HIT for player 1) + (CAP HIT for player 2) + (CAP HIT for player 3) + ... + (CAP HIT for player (n))


here are my xml and xsl file:
- http://alinmateescu.name/nhl/xsl/info.xsl
- http://alinmateescu.name/nhl/xml/tor.xml

and here's what i have done so far:
- http://alinmateescu.name/nhl/index.php




any help would be much appreciated.

thanks.
 
Old August 18th, 2006, 02:37 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Google for "XSLT sum of computed values" - you'll find a lot of ideas on this topic. In XSLT 2.0 it's easy, because you can apply sum() to a sequence of numbers that can be computed using any expression, e.g.

sum(for $i in player return sum($i/payment))

In 1.0 it's more difficult; if you're stuck with 1.0, take a look at Dimitre Novatchev's FXSL library.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 18th, 2006, 09:06 AM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks, Michael.

i'll see what i can find from the search you mentioned, and how the FXSL library can help.


unfortunately, i can't use XSLT 2.0. i use PHP to output the XML/XSLT into html, and the PHP code is giving me this error:
Quote:
quote:
PHP Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///D%3A/xsl/info.xsl line 2 element stylesheet in D:\ssi_xml.php on line 13 PHP Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: xsl:version: only 1.0 features are supported in D:\ssi_xml.php on line 13
this is the PHP code:
Code:
Function ShowRSS($xml_file, $xsl_file){

$xsl = DOMDocument::load($xsl_file);
$xml = DOMDocument::load($xml_file);

//create the processor and import the stylesheet
$proc = new XsltProcessor(); 
$xsl = $proc->importStylesheet($xsl);
//$proc->setParameter(null, "value", "0"); 

//transform and output the xml document
$newdom = $proc->transformToDoc($xml); 
print $newdom->saveXML(); 

}

ShowRSS('xml/tor.xml', 'xsl/info.xsl');





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:param and xsl:apply-templates' "select" newbieboobers XSLT 1 March 25th, 2008 07:23 PM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
differnce between xsl:apply-templates and xsl:call chandu.mca007 XSLT 2 June 12th, 2007 04:12 AM
xsl advise needed - Replacing UID through XSL Billyl XSLT 6 February 28th, 2006 05:46 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.