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 2nd, 2007, 06:51 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks very much you saved my life. name can also be used for XSLT 1.0 right? I am trying it now.

Your attitude determines your altitude
 
Old February 2nd, 2007, 07:07 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The last question. How can I show the value of a param element(I have only used variable since now and with <xsl:value of select ="elementname"/> I had no chance.I have no choice to use document() function in XSLT 1.0 under .NET I am getting en error message like

Execution of the 'document()' function was prohibited. Use the XsltSettings.EnableDocumentFunction property to enable it

Your attitude determines your altitude
 
Old February 2nd, 2007, 08:32 AM
Registered User
 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i think what you are after is;

<xsl:template match="whatever">
 <xsl:param name="elementname">


<xsl:value-of select="$elementname" />



For this to work you must pass the 'elementname' parameter to the template when you call it like joefawcett stated

Hope that helps and i understood what you were after

/Matt


 
Old February 2nd, 2007, 08:40 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I made a silly mistake I have forgotten to reference it fro call-template. Ok my problem has been solved.
 
Old February 2nd, 2007, 04:02 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

One little point: instead of

<xsl:variable name="messageDate">
            <xsl:value-of select="./messagedate"/>
        </xsl:variable>

you should write

<xsl:variable name="messageDate" select="./messagedate"/>

It's one line of code instead of three so it's more readable, and it's also more efficent because it doesn't involve creating a result tree fragment.


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old February 3rd, 2007, 01:04 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

1. Change your existing template to:

<xsl:template match="messagedate">
  <xsl:call-template name="check-date">
        <xsl:with-param name="date" select="./messagedate"/>
  </xsl:call-template>
</xsl:template>

2. Write the named template:

<xsl:template name="check-date">
  <xsl:param name="date"/>
  <xsl:variable name="cc" select="substring($date,1,2)"/>

etc: as your existing code, but changing $messageDate to $date.

3. "I have to make this for all elements like messagedate" - call the named template for other date elements in the same way as it is called above for messagedate.

4. "it should also give the attribute name as the element name in which I have to use it." - I don't understand this part of your question.

Really, you should be checking leap years. That means you are better off using a standard library routine rather than coding this yourself. If you can, move to XSLT 2.0 and use "castable as xs:date".




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
garbage collection generalization tapan General .NET 2 April 27th, 2007 07:13 AM
template uicdbd XSLT 5 March 15th, 2007 12:54 PM
template uicdbd XSLT 1 March 14th, 2007 05:16 PM
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.