Subject: Re: [xsl] String conversion problem when string is large From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Wed, 21 Mar 2012 13:16:31 -0400 |
I have much to learn. Those two things look identical to me.
Sadly, it's a very common mistake. Any variable-like element with content (xsl:variable, xsl:param, xsl:with-param) creates a temporary tree; in this case a tree containing a document node and a single text node child. That's a much more heavyweight data structure than a simple string, as your memory problems demonstrate. It behaves like a string in most circumstances, but not all - for example, conversion to a boolean behaves differently. That makes it quite hard to optimize. Saxon does its best by using a special tree model that can only hold a document node with a single text node child. I happened to notice in your stack trace that this wasn't being used here, it was using a standard TinyTree - I'm not sure why the optimization isn't kicking in, there can be any number of reasons. But using a string is so much better, it reduces the size of your code and makes all this optimization effort (which is really just amelioration of bad code) completely unnecessary.
Even better, declare it as a string so the optimizer knows what to expect!
<xsl:param name="string" as="document-node()"> <xsl:document>string</xsl:document> </xsl:param>
Thanks as always, 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] String conversion problem, Michael Kay | Thread | Re: [xsl] String conversion problem, Michael Kay |
Re: [xsl] Stylesheet analysis/docum, team wise | Date | Re: [xsl] String conversion problem, Michael Kay |
Month |