473,394 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Passing Parameters

Hello everyone,

I am relatively new to XML, and I'm having trouble multiplying parameters that I passed in from an XML document using using XSLT.

Here is my XML file:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Teacher.xsl"?>
<pay>
<sub1>30</sub1>
<hourlyRate>15.75</hourlyRate>
</pay>


Here is my XSLT file:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="pay">
<html>
<body>
<xsl:apply-templates select="sub1"/>
<xsl:apply-templates select="hourlyRate"/>
<xsl:value-of select="$onevariable*$twovariable"/>
</body>
</html>
</xsl:template>
<xsl:template match="sub1">
<xsl:param name="onevariable"/>
<br/><xsl:value-of select = "$onevariable"/>
<br />Hours: <xsl:value-of select="."/>


</xsl:template>
<xsl:template match="hourlyRate">
<xsl:param name="twovariable"/>
<br/><xsl:value-of select="$twovariable"/>
<br />Pay Rate: <xsl:value-of select="."/>



</xsl:template>
</xsl:stylesheet>



Basically, I have to to multiply onevariable and twovariable with the "$". I don't where in the document to declare it.


Thanks in advance for anyone who can help me with this problem.

(Sorry if the thread is long.)
Nov 30 '08 #1
2 1867
Dormilich
8,658 Expert Mod 8TB
Hi compGam,

in your case use the self::node() wildcard (.).
Expand|Select|Wrap|Line Numbers
  1. <xsl:param name="onevariable" select="."/>
you could also define it just before the computation:
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name="onevariable" select="//sub1"/>
you could even use:
Expand|Select|Wrap|Line Numbers
  1. <xsl:value-of select="number(//sub1/text())+number(//hourlyRate/text())"/>
more on parameters: XML.com: Setting and Using Variables and Parameters

and one more thing:

For the benefit of our experts and yourself, it is a posting guidelines that all users use [code] tags when posting code. This makes the code easier to read and, in turn, helps our experts answer your questions.

An easy way to do this is to highlight the code in the textarea and then hit the '#' button at the top of the textarea.

Please read the Posting Guidelines so you're more familiar with how things work.

regards
Nov 30 '08 #2
jkmyoung
2,057 Expert 2GB
not sure if you're doing one thing or the other...

Where are you declaring these variables?
Don't forget when you declare a parameter in a template, it's only works inside that template. You can't use it when it comes back.

Instead of
<xsl:value-of select="$onevariable*$twovariable"/>
try:
<xsl:value-of select="sub1 * hourlyRate"/>
Dec 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
7
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
12
by: Joel | last post by:
Hi all, Forgive me if I've expressed the subject line ill. What I'm trying to do is to call a c++ function given the following: a. A function name. This would be used to fetch a list of...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
17
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int...
4
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
2
by: csmith8933 | last post by:
How do I write a function where the number of parameters it takes varies? This is what I have but it doesnt work. // function prototype void functionThree(int num1=1, int num2=2, int num3=3);...
3
by: ajaymohank | last post by:
hello everyone..... i am ajay and i am new to php. in my project i have an option to invoke a bat file by passing parrameters and to diplay the result. i tried this code but my page got hung or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.