Subject: Re: [xsl] String conversion problem when string is large From: Michael Kay <mike@xxxxxxxxxxxx> Date: Wed, 21 Mar 2012 17:52:11 +0000 |
Just to confirm, do I read correctly thatYes, that's correct. Technically a document is constructed and then atomized to create the string, but it doesn't require a great deal of brain-power to short-circuit this.
<xsl:param name="string" as="xs:string">string</xsl:param>
will be passed and processed as a string rather than a tree?
Since most XSLT 2.0 processors are closed source, we have no way of knowing.
I have been working in the belief (also in analogous cases) that it does, but as long as we're on the topic I wonder if you can speak to it.
Plus, I am wondering whether I can know that this will happen in any XSLT 2.0 processor, not only Saxon.
Well, there are other benefits in declaring the type. These two constructs aren't equivalent, because in the first case the processor knows that the value will always be a string, whereas in the second it's only a string in the case where it's defaulted.
The main reason I need this settled in my mind is that, as you say, this comes up very commonly; and one of the most mystifying pieces of advice we give to beginners is to prefer using @select, when possible, to a literal value in a parameter or variable assignment, even though the latter is legal and it works, under one definition of "work". If the workaround is really this easy (and if it even suggests the nature of the underlying problem, as this appears to), that might help.
In other words, if
<xsl:param name="string" as="xs:string">string</xsl:param>
is long for
<xsl:param name="string" select="'string'"/>
Yes, that's true.
we should see similarly that
<xsl:param name="string">string</xsl:param>
is another way of saying
<xsl:param name="string" as="document-node()"> <xsl:document>string</xsl:document> </xsl:param>
Is this correct?
Michael Kay Saxonica
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] String conversion problem, Wendell Piez | Thread | Re: [xsl] String conversion problem, Wendell Piez |
Re: [xsl] String conversion problem, Wendell Piez | Date | Re: [xsl] String conversion problem, Wendell Piez |
Month |