Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| 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 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
  #1 (permalink)  
Old January 9th, 2006, 10:12 AM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default calling template from a href

Hi all.

Does anyone know if it is possible to call a template from a href. Or if not how to call a template from a users action through html?

I have a 3 xml out puts in which I would like to supply three links on the screen in html. When one link is clicked I want the one output to be invoked and if the user clicks on the other link, to call another template to invoke that data. And again if the third link is clicked for that template to be invoked displaying the xml 3 information. These templates are all seperate and I want the display to be seperate. I know how to code the if test statements jsut unsure on the code for the href call template..

<a href="{call-template name="user"}">user</a>
<a href="{call-template name="manager"}">manager</a>
<a href="{call-template name="dev"}">dev</a>

I know this is wrong but this is the bit of code that I need help on!
Anyone with any ideas?? Ill keep trying and let you know if I crack it!

Thanks in advance!


  #2 (permalink)  
Old January 9th, 2006, 11:56 AM
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've got the processing model confused. First the XML is transformed into HTML using the stylesheet. Then this HTML is displayed in the browser. When the user clicks on something, the transformation has long finished.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #3 (permalink)  
Old January 9th, 2006, 12:20 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, maybe I was not clear enough.. Consider the below XML file:

<edit>
<user>
<ROWSET>
<ROW num="1">
<USERID>1</USERID>
<GROUPID>4</GROUPID>
<UNAME>name</UNAME>
<USURNAME>edit</USURNAME>
<UEMAIL>aneamil@</UEMAIL>
<UPASSWORD>apassword</UPASSWORD>
</ROW>

<ROW num="2">
<USERID>2</USERID>
<GROUPID>4</GROUPID>
<UNAME>aperson</UNAME>
<USURNAME>asurname</USURNAME>
<UEMAIL>something</UEMAIL>
<UPASSWORD>apassword</UPASSWORD>
</ROW>

<manager>
<ROWSET>
<ROW num="1">
<MANAGERID>203</MANAGERID>
<GROUPID>2</GROUPID>
<MNAME>aperson</MNAME>
<MSURNAME>asurname</MSURNAME>
<MEMAIL>aneamil@address<</MEMAIL>
<MPASSWORD>apassword</MPASSWORD>
</ROW>
<ROW num="2">
<MANAGERID>203</MANAGERID>
<GROUPID>2</GROUPID>
<MNAME>aperson</MNAME>
<MSURNAME>asurname</MSURNAME>
<MEMAIL>aneamil@address</MEMAIL>
<MPASSWORD>apassword</MPASSWORD>
</ROW>
</ROWSET>
</manager>

</edit>

I need to create a stylesheet that has a link in the html. These links reference the template want to call, in this case the template is:

<xsl:call-template name="user" />

This will display a table in which you can see all the users information.

Then if I then click on a link within the html document eg. "manager" then I want all the manager details to be displayed instead of the users by using:

<xsl:call-template="manager" />

Do you know if this is possible??

Thanks for the reply!

  #4 (permalink)  
Old January 9th, 2006, 12:34 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

When the user clicks, you want to execute some JavaScript which fires off a new XSLT transformation and places the result in the HTML page. The new transformation can use a different stylesheet, or it can use the same stylesheet with different parameters (or a different source document). You'll find examples of this in the appendix of my book dealing with MSXML.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #5 (permalink)  
Old January 9th, 2006, 01:11 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply.

Ill take a look at the book now.



Similar Threads
Thread Thread Starter Forum Replies Last Post
calling template with javascript smys123 XSLT 3 November 22nd, 2007 04:13 AM
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 one template in other template VijayKumar XSLT 3 September 15th, 2005 11:12 AM





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