|
Subject:
|
Help with XSL
|
|
Posted By:
|
FRANTIC
|
Post Date:
|
8/17/2006 8:57:53 PM
|
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.
|
|
Reply By:
|
mhkay
|
Reply Date:
|
8/18/2006 2:37:18 AM
|
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
|
|
Reply By:
|
FRANTIC
|
Reply Date:
|
8/18/2006 9:06:52 AM
|
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:
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:
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');
|