On 03/10/2011 22:26, G. Ken Holman wrote:
At 2011-10-03 14:19 -0700, Mark wrote:
I have been using the following idiom when providing a value for
“select†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>
The above is a text node, as is this:
<xsl:param name="file-type">.htm</xsl:param>
Actually, no. Both are document nodes (known in 1.0 as root nodes)
having a single text node as a child.
This is slightly different in that it is a string:
<xsl:param name="file-type" select="'.htm'"/>
But for your use that difference is nuanced based only on how the item
is stored in memory.
If the system isn't able to do some quite sophisticated optimizations,
it's very likely that a tree containing a document node and a text node
will be much more expensive than a simple string. They are equivalent in
most situations, but not all, which means the optimizer can't always
replace one with the other. The main difference is the effective boolean
value: <xsl:if test="$file-type"> works differently for strings and nodes.
Why write three lines of inefficient code where one line of efficient
code will do the job?
(Saxon will do the optimization, incidentally, if every reference to
$file-type appears in a context where the value of the variable is
atomized.)
Michael Kay
Saxonica
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--