xsl-list
[Top] [All Lists]

Re: [xsl] String conversion problem when string is large

2012-03-20 18:50:37


Try changing this:

            <xsl:with-param name="HexData">
              <xsl:value-of select="substring-after($HexData, ',')" />
            </xsl:with-param>

to this:

            <xsl:with-param name="HexData" select="substring-after($HexData, ',')" 
/>

Passing the parameter as a string will be MUCH more efficient than passing it 
as a TinyTree.

...

That resulted in success.

...
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-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>
--~--