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 May 17th, 2007, 08:16 PM
Registered User
 
Join Date: May 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default href in xslt

I have a xml file with list of student names.And I wrote a xslt style sheet to transform the xml to a xhtml.In the xhtml,when i click on a students name,I want it to be able to scroll down to the respective students name.

For example: the xml document is

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="a.xsl"?>

<list>

<student>
  <name> paul scholes </name>
  <adres>old trafford,manchester,england</adres>
 </student>

 <student>
  <name> david beckham </name>
  <adres>real madrid,spain</adres>
 </student>
</list>

and the XSLT style sheet code is :

 <xsl:template match="/">
  <h3>list of students:</h3>
  <xsl:for-each select="list/student">

   <xsl:value-of select="name"/>
   <br/>
  </xsl:for-each>

  <h3>student's addreses:</h3>
  <xsl:for-each select="list/student">
   [u]<xsl:value-of select="name"/></u><br/>
   <xsl:value-of select="adres"/>
   <br/>
  </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>



and a sample xhtml output is:

list of students:
paul scholes
david beckham

student's addreses:
paul scholes
old trafford,manchester,england
david beckham
real madrid,spain





So for example,in the list of students,when i click on the name paul scholes,it should be able to scroll down and show the underlined paul scholes and his address.

hope you get what i intend to.

Can some one guide or tell me what code to add to make the above work?

If you add the code for me..that would be really helpfull too.thanx alot.

 
Old May 17th, 2007, 09:07 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

Hi, You can use the @name and @href attributes of th <a> element.
Code:
 <xsl:template match="/">
  <h3>list of students:</h3>
  <xsl:for-each select="list/student">
   <a>
     <attribute name="href"><xsl:value-of select="name"/></attribut>
     <xsl:value-of select="name"/>
    </a>
   <br/>
  </xsl:for-each>

  <h3>student's addreses:</h3>
  <xsl:for-each select="list/student">
   [u]   
<a>
   <attribute name="name"><xsl:value-of select="name"/></attribut>
   <xsl:value-of select="name"/>
 </a>
</u>
<br/>
   <xsl:value-of select="adres"/>
   <br/>
  </xsl:for-each>  
 </xsl:template>
</xsl:stylesheet>
 
Old May 18th, 2007, 07:39 PM
Registered User
 
Join Date: May 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx for the reply.but i figured out a alternative working solution.Just adding in .

<xsl:template match="/">
   <h3>list of students:</h3>
   <xsl:for-each select="list/student">
     <a href="#student{position()}"><xsl:value-of select="name"/></a>
     <br/>
   </xsl:for-each>

   <h3>student's addreses:</h3>
   <xsl:for-each select="list/student">
     <a name="student{position()}">
       [u]<xsl:value-of select="name"/></u>
     </a>
     <br/>
     <xsl:value-of select="adres"/>
     <br/>
  </xsl:for-each>
 </xsl:template>






Similar Threads
Thread Thread Starter Forum Replies Last Post
using href in xslt rajesh_css XSLT 0 September 18th, 2008 02:44 AM
Saving XML thru href link using XSLT kaukabhishek XSLT 16 June 25th, 2008 07:16 PM
Chapter 8, href and HRef (p. 285) roman BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 June 16th, 2008 10:40 AM
Want to pass value at href in anchor tag on xslt Abhinavnaresh XSLT 4 February 21st, 2008 04:32 AM
href darkhalf Javascript 2 November 20th, 2005 10:59 AM





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