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 April 24th, 2007, 05:03 PM
Registered User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default financial parsing

Hello,

I have an xmlnode containing data about the financial results of a company, like this:

<company>
........
<financial>
<income>345000</income>
<expense>256100</expense>
</financial>
</company>

I wrote an xslt template, to get the result:

<xsl:template name="mycalc">
<xsl:param name="a"/>
<xsl:param name="b"/>
<xsl:value-of select="$a-$b" />
</xsl:template>

template call:

<xsl:call-template name="mycalc">
<xsl:with-param name="a" select="income" />
<xsl:with-param name="b" select="expense" />
</xsl:call-template>

I got an error:

Unexpected 'eof'token: '$'. $a--->$<--b.
Can anyone tell me the right way to use the "-" operator? "/" also returns an error, "+" and "*" were OK.

Thanks in advance!


 
Old April 24th, 2007, 05:17 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XML allows hyphens in names, so the minus operator must be separated from a preceding name by a space.

Comes naturally to COBOL old-timers...

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 25th, 2007, 05:05 PM
Registered User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx,

it works with space around the hyphen.
just for curiosity, how can you solve with the "/" divide character?
Space is not a good point any more, in that case. It triggers an error:

Nodetest required $a / -->$<--b. !!!

 
Old April 25th, 2007, 05:13 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Here is s great site to help you out...

http://www.w3schools.com/xpath/xpath_operators.asp



 
Old April 25th, 2007, 05:20 PM
Registered User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx,

full description of all I wish.


 
Old April 26th, 2007, 02:55 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The divide operator in XPath is not "/", it is "div". "/" is a path operator. And of course, "div" must be separated from its operands by spaces (there's been some debate about whether "1div2" is legal in XPath 1.0, I forget the outcome, but adding spaces certainly does no harm!)

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML parsing denzil_cactus Perl 0 June 11th, 2007 02:34 AM
XML Parsing SCADA_Monkey XML 2 March 11th, 2007 03:20 PM
Parsing mwviola98 SQL Language 4 July 21st, 2005 10:35 AM
XML Parsing tgopal .NET Web Services 1 June 15th, 2004 03:25 AM
Parsing in PHP Walter G Pro PHP 2 August 14th, 2003 01:54 AM





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