Our thread test driver is running 20 threads on a 8 processor box. Each thread is performing the same set of 16 different transformations (in a couple of different orders). Each transformation is performed by a SAX processing chain. The XSL transforms are loaded into templates. The classes used in the SAX processing chain are recreated for each transformation.
In the first example, a local variable is passed to two separate templates. The value of the IntermediateValue variable changes between the two xsl:call-template invocations. The incorrect value can be found in the input XML. We believe the incorrect value is being picked up from another thread. This error will generally occur once or twice every 10 runs (of the 20 threads).
<xsl:template match="sep-gmt-post-timestamp" priority="20.0">
<xsl:variable name="IntermediateValue"
select="concat(normalize-space(.),
substring-after(../event-creation-timestamp,'Z'))" /> <xsl:call-template name='TransformField'>
<xsl:with-param name="IntermediateValue"
select="$IntermediateValue" /> <xsl:with-param name="OtherElements">
<xsl:call-template name="FormatDateTime">
<xsl:with-param name="Input">
<xsl:value-of select="$IntermediateValue" />
</xsl:with-param>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:template>The other error occurred on almost every test run. A local variable inside of a recursive template call appeared to be changing. The "count" was sometimes '1' when it should have been '0'. We totally eliminated the local variables and the problem when away. I've included old and new code fragments:
<!--Original/Broken Code-->
<xsl:template name="OutputFieldAndValue">
<xsl:param name="count" />
....
<xsl:variable name="paddingSpaces">
<xsl:value-of select="$num * 4" />
</xsl:variable>
....
<xsl:variable name="calculatedPadding">
<xsl:value-of
select="substring($TranslatedSpaces,1,$paddingSpaces)" />
</xsl:variable>
....
<xsl:for-each select="*">
<xsl:call-template name="OutputFieldAndValue">
<xsl:with-param name="count" select="$count+1" />
</xsl:call-template>
</xsl:for-each>
....
</xsl:template>
<!--New/Working Code--> <xsl:template name="OutputFieldAndValue"> <xsl:param name="count" select="0" /> <xsl:param name="indent" select="''" /> .... <xsl:for-each select="*"> <xsl:call-template name="OutputFieldAndValue"> <xsl:with-param name="count" select="$count+1" /> <xsl:with-param name="indent" select="substring($TranslatedSpaces,1,$count*4)" /> </xsl:call-template> </xsl:for-each> .... </xsl:template>
-- Edward L. Knoll Phone (FedEx) : (719)484-2717 e-mail (FedEx) : [EMAIL PROTECTED] e-mail (personal) : [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
