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 January 24th, 2006, 10:52 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default XSL - Parameter query.

Hi,

I know this may appear easy but please can someone help.

In the example below, am I right in thinking that:

1.
The Parameter name is 'ToOrFrom'

2.
The value to be passed is 'From'

3.
The template to be called is 'DeliveryNotificationHeader'.


<xsl:call-template name="DeliveryNotificationHeader">
    <xsl:with-param name="ToOrFrom">From</xsl:with-param>
</xsl:call-template>


I have had limited experience in this field.

Many thanks,




Neal

A Northern Soul
__________________
Neal

A Northern Soul
 
Old January 24th, 2006, 11:56 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Yes, almost. In fact the value of the parameter is a result-tree-fragment consisting of a document node that owns a text node whose value is "From". For most practical purposes this will behave exactly like passing the string "From", but it's a lot less efficient. It's better to pass the string itself:

<xsl:with-param name="ToOrFrom" select="'From'"/>

Note the nested quotes.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 24th, 2006, 12:22 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Excellent, very prompt.

So, are there any beneifts in the original code?

(FYI - The template is a separate XSL form)

Thanks again,



Neal

A Northern Soul
 
Old January 24th, 2006, 01:25 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

There are obviously cases where you do need to build a real result tree fragment (typically it will contain elements) but an RTF that only contains a single text node is always pointless.

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

Having said that, there's one case I use them which is

<xsl:variable name="quote">"</xsl:variable>

which is purely for the convenience of not having to escape the quotes.

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
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
How to increment/decrement a parameter in XSL tclotworthy XSLT 2 February 9th, 2007 04:24 PM
XSL Variable and/or Parameter Question ripple XSLT 9 September 1st, 2006 12:16 PM
USING PARAMETER INSIDE XSL:TEXT cleytonjordan XSLT 6 July 29th, 2005 07:30 PM
XSL Parameter xsl:param Harinath Chikoti XSLT 1 May 6th, 2005 03:15 AM





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