?
Solved

Change xsl param using javascript

Posted on 2008-06-13
6
Medium Priority
?
1,104 Views
Last Modified: 2013-11-18
Hi there,

I'm trying to change the 'select' value of an 'xsl:param' tag I have at the top of an xsl. I would like it to take on the value of a variable I define elsewhere, and it seems that javascript would be the best way of doing this, as I do not have access to server side technologies, such at php or asp.

I'm trying to do this to reduce the number of xsls I'll need to produce, one for every combination needed would mean creating over 4000 files, which seems a bit much when it appears logical to change a param value, based on an aggregation of a few variables, which change depending on what the user has selected.

It would be great to know how/ whether with is possible, or if there are easier ways to solve this problem.

Thanks.
0
Comment
Question by:km_team
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 21779097
>>Change xsl param using javascript. I'm trying to change the 'select' value of an 'xsl:param' tag I have at the top of an xsl.
Javascript does not process the xsl so you cannot do that directly. You will need to post some code or provide the url to you page. Not sure what you are doing, but it sounds like you need to pass parameters to your xsl processor.
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 21779119
Look at the accepted solution here:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XSLT/Q_22940685.html

Notice how in showTable(), the parameter is being passed to the processor via:
xsltProc.setParameter('', 'stateid' , stid);
0
 

Author Comment

by:km_team
ID: 21779550
Just to make it a bit clearer, I have a parameter such as this at the top of each XSL:

<xsl:param name="selected" select="portfolio_management/content[country='Ireland' or region='Group'][lob='Motor' or lob='All'][area='PSS' or alt1a='PSS' or alt2a='PSS']" />

I'm then using: <xsl:for-each select="$selected"> inside the main template to ensure that only the records which meet the above criteria are selected.

The value of the parameter changes however, and depends on country, lob and area.  To create one XSL for each of the combinations of country, lob and area that a person could want to view, means making over 4000 XSLs.  
I'm trying to find a way to reduce the number of XSLs needed.  It would be lovely to be able to refer to the parameter outside of the XSL and change it depending on the selections a user has made, but, as ever, the simplest ideas never truly are so.  
I've had a look at Xquery, but I don't think it's quite what I'm after.  

Thanks for your help so far (I'm using sarissa at the moment to change the XSLs used with the XML in a div of my HTML)  however something a bit more specific would be wonderful.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 82

Expert Comment

by:hielo
ID: 21779964
>>I would like it to take on the value of a variable I define elsewhere
OK, but it's not clear what that parameter would be. For the sake of argument, let's say that you want to select based on the country selection. So what you would need to do is put:
<!-- make ireland your default country name; that is what will be used if the parameter is specified -->
<param name="country" select="'ireland'"/>

then at the place where you need to "execute" the query you would use:
<xsl:param name="selected" select="portfolio_management/content[country='$country' or region='Group'][lob='Motor' or lob='All'][area='PSS' or alt1a='PSS' or alt2a='PSS']" />

but you will need to pass the parameter country to the xsl file:
xsltProc.setParameter('', 'country' , 'england');//this will override the default value in the xsl -> 'ireland'
0
 

Author Comment

by:km_team
ID: 21793202
Ahh, that's marvellous.

Just one further wonder, in that I won't always have all of the selections, eg some times it will be this:

<xsl:param name="selected" select="portfolio_management/content[country='$country' or region='Group'][lob='Motor' or lob='All'][area='PSS' or alt1a='PSS' or alt2a='PSS']" />

other times it may just be this:

<xsl:param name="selected" select="portfolio_management/content[country='$country' or region='Group']"/>

...depending on what has been selected.

Is there a catch all  that I could change the value of country to, for example, if wanting to display all countries but still filter by lob and area?
0
 
LVL 82

Expert Comment

by:hielo
ID: 21842233
You can have as many <param> as you need. There is no "catch all", but you could have/define all the necessary params that you need to determine whether a particular value/selection was made.
0

Featured Post

Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question