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 July 10th, 2007, 06:57 AM
Authorized User
 
Join Date: Jan 2006
Location: tel aviv, israel, Israel.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default template calling

hello

I have 2 templates that look pretty the same with one different. in one there is attribute apiNode and in the other there isnt.
I would like to make out of them one template that with an 'if' function I would know which to call (the one with the apiNode or the one with out). in a simple words, is there a function that will check if there is apiNode (boolean or something)
this are the 2 templates
<xsl:template name="group-column">
    <xsl:param name="key" select="''"/>
    <xsl:param name="apiNode" select="''"/>
    <xsl:param name="apiImport" select="''"/>
        <xsl:attribute name="key">
            <xsl:value-of select="$key"/>
        </xsl:attribute>
        <xsl:attribute name="apiNode">
            <xsl:value-of select="$apiNode"/>
        </xsl:attribute>
        <xsl:attribute name="apiImport">
            <xsl:value-of select="$apiImport"/>
        </xsl:attribute>
</xsl:template>
<xsl:template name="generalKeyDisplay">
    <xsl:param name="key" select="''"/>
    <xsl:param name="display" select="''"/>
    <xsl:attribute name="key">
        <xsl:value-of select="$key"/>
    </xsl:attribute>
    <xsl:attribute name="display">
        <xsl:value-of select="$display"/>
    </xsl:attribute>
</xsl:template>

thank you


Reply With Quote
  #2 (permalink)  
Old July 10th, 2007, 07:16 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

Well, there seems to be more than one difference to me: one template is outputting key, apiNode, and apiImport, while the other is outputting key and display. To me, there doesn't seem to be enough commonality to justify making a single template with conditional logic. But you can always do it if you want: create a single template with four parameters and four calls on xsl:attribute, each surrounded by xsl:if:

<xsl:if test="$key != ''">
  <xsl:attribute name="key">
    <xsl:value-of select="$key"/>
  </xsl:attribute>
</xsl:if>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
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
calling template with javascript smys123 XSLT 3 November 22nd, 2007 04:13 AM
template calling kgoldvas XSLT 1 August 1st, 2007 10:20 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 09:47 PM.


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