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 February 20th, 2008, 09:45 AM
Registered User
 
Join Date: Feb 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Want to pass value at href in anchor tag on xslt

I am using XSLT transformation to display XML file in ASP.NET 2.0 and I want to make A table of content similar as in the page of following link given .
http://www.w3.org/TR/REC-CSS2/selector.html


My Code of xslt page is :


Code: ( text )
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

  <xsl:template match="/">
    <html>

    <body>

      <xsl:apply-templates/>
    </body>
  </html>
</xsl:template>

<xsl:template match="TARGETCATEGORY">
      <table border="2" BorderColor="#DEBA84" height="50px" Width="436px" layout="fixed">
      <tr><td colspan="2">
         <a href="#{@Name}"><xsl:value-of select="@Name"/></a>
          <xsl:variable name="node1">
          <xsl:value-of select="@Name"/>
          </xsl:variable>
      </td></tr>
    </table>
       <xsl:apply-templates/>
 </xsl:template>

<xsl:template name="sub" match="SUBCATEGORY">
<table border="2" BorderColor="#DEBA84" Width="436px" layout="fixed">
         <tr><td colspan="2">
              <a href="@Name" onClick="count(i=i+1); return;"><xsl:value-of select="@Name"/></a>
             <a name="Top"></a>
          </td></tr>
    </table>

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




I want to assign a number to each anchor tag dynamically.

Please help me.......!!!!!!!!!!!!!!!!!!!!
thanks in advance.


Abhinav
 
Old February 20th, 2008, 09:57 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

There is the xsl:number instruction which has many uses but can be used to produce a sequential number.

<a href="{@Name}"><xsl:attribute name="onClick"><xsl:text>count(</xsl:text><xsl:number select="//SUBCATEGORY"/><xsl:text>) return;</xsl:text></xsl:attribute>

/- Sam Judson : Wrox Technical Editor -/
 
Old February 20th, 2008, 09:59 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I want to assign a number to each anchor tag dynamically

Possible solutions include

position()

<xsl:number/>

count($x/preceding::node())

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old February 21st, 2008, 12:25 AM
Registered User
 
Join Date: Feb 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello Sam
i am following the tag given by you.
Thanks for that.
Sam now i am again facing an other problem that is in xsl:number tag, it is showing that
"'select' is an invalid attribute for the 'xsl:number' element."

Please help me.

Quote:
quote:Originally posted by samjudson
 There is the xsl:number instruction which has many uses but can be used to produce a sequential number.

<a href="{@Name}"><xsl:attribute name="onClick"><xsl:text>count(</xsl:text><xsl:number select="//SUBCATEGORY"/><xsl:text>) return;</xsl:text></xsl:attribute>

/- Sam Judson : Wrox Technical Editor -/
Abhinav
 
Old February 21st, 2008, 04:32 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The select attribute was added to xsl:number in XSLT 2.0. I suggest you don't copy Sam's code without understanding it - rather go and read the spec and see how you can use these facilities to design your own solution to your problem.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Anchor Tag kapilmirchi ASP.NET 1.0 and 1.1 Basics 2 November 18th, 2008 05:57 AM
Anchor tag visited CSS related question mat41 Classic ASP Basics 0 April 16th, 2008 05:55 PM
place anchor tag around bgImage inside cell?? mat41 HTML Code Clinic 4 January 26th, 2006 07:42 AM
Problem with input type image With Anchor tag vinkumrect Javascript How-To 1 July 21st, 2005 08:59 AM
Javascript in Anchor Tag jamara JSP Basics 1 May 30th, 2005 01:00 AM





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