Subject: Re: [xsl] Providing a value for the 'select' attribute From: "Mark" <mark@xxxxxxxxxxxx> Date: Mon, 3 Oct 2011 15:43:21 -0700 |
Hi, I have been using the following idiom when providing a value for bselectb in statements like <xsl:param>, <xsl:variable>, etc., when the value provided is not an xsl object. Is this correct or is some other form preferred?
<xsl:param name="file-type"> <xsl:text>.htm</xsl:text> </xsl:param>
This is not incorrect. So it is correct. Some, however (including some readers of this list), would argue that it is not optimal.
In essence, absent a specification otherwise (using xsl:param/@as), you are declaring the paramater to be a temporary tree (or, in XSLT 1.0, a result tree fragment), in this case a root with a single text node child.
(which is essentially the same as what you have with as="xs:string" added, since the effect of the xsl:text is cosmetic).
Advantages to binding to a string instead of a temporary tree include that it will be faster when it is processed as a string (since it won't have to be cast to one); and that it will probably behave more as you expect it to when under stress ... for example, a string value of "" is cast to Boolean false(), while a temporary tree with a single text node will cast to Boolean true(), even if that text node has no string value.
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Providing a value for the, Wendell Piez | Thread | [xsl] Error: sequence of more than , Mark |
Re: [xsl] XSLT Patterns, Andrew Welch | Date | Re: [xsl] Providing a value for the, Michael Kay |
Month |