Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 21st, 2007, 03:55 PM
Authorized User
Points: 101, Level: 2
Points: 101, Level: 2 Points: 101, Level: 2 Points: 101, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2007
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default calling template with javascript

I need an onclick function to call an xsl template and am having trouble doing so

<script type="text/javascript">
function load()
{
  <xsl:call-template name="thename" />
}
</script>

<a href="#" onclick="load()">load it</a>


the above code is an example of what I have on one particular template in an xsl file....I need the onclick event to load the other template, also on the same xsl file.

any suggestions
Reply With Quote
  #2 (permalink)  
Old June 21st, 2007, 05:17 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You can't put an XSLT instruction in the middle of your Javascript code any more than you can put a Javascript instruction in the middle of a C program.

What you can do is to invoke a stylesheet transformation using the API provided by your XSLT processor. This starts the XSLT processing at the top level - it must supply an input document to be processed, and the stylesheet produces an output document which the Javascript code can then manipulate (typically by displaying it).

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old November 21st, 2007, 05:35 PM
Registered User
 
Join Date: Nov 2007
Location: Halifax, , Canada.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm new to XSLT (Like most people here it seems) but I'm soaking up as much info as I can and this forum has been excellent.

When I started out, this was also probably my original plan of action as well.

I now understand that (correct me if I'm wrong) that if the XML is transformed via the XSL stylesheet on loading in the browser, that and javascript changes will not affect the output unless the page is reloaded with new templates to apply. And that call-template and apply-template are processed during (and only during) transformation.

That being said, is there a way to take a global javascript variable and make it equal in value to a global XSL parameter so that the user can input a value and the transformation will be loaded into an iframe?

(I thought that asking a straightforward question first might be smarter than pasting my huge pages of code and asking "WHY ISN'T THIS WORKING THE WAY I WANT IT TO?!"

Thanks in advance.

Reply With Quote
  #4 (permalink)  
Old November 22nd, 2007, 04:13 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You can't do what you want via a transform kicked off via an xsl-stylesheet processing instruction. The standard way to do it is to have some script in an HTML page that reads the location.search and then invokes the transformation after setting the necessary parameter.

--

Joe (Microsoft MVP - XML)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
template calling kgoldvas XSLT 1 August 1st, 2007 10:20 AM
template calling kgoldvas XSLT 1 July 10th, 2007 07:16 AM
CALLING A TEMPLATE WITHIN JAVA SCRIPT SOMANATHAN10 XSLT 6 February 14th, 2007 02:10 AM
calling template from a href bergs77 XSLT 4 January 9th, 2006 01:11 PM
calling one template in other template VijayKumar XSLT 3 September 15th, 2005 11:12 AM



All times are GMT -4. The time now is 12:04 PM.


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