|
|
Rank: Newbie
Joined: 8/6/2009 Posts: 4 Location: NL
|
Hi all,
I'm trying to add a item to a HashTable (using xml and xslt 2.0 and the .net extension). The only problem is that i get errors like "CSharp execution error - 'Error: Exception has been thrown by the target of an invocation.' - hashtable:Add". After some research i found out that if i added a clear call to the variable containing the hash there where no errors any more.
Is there any one who known why this is?
My Xslt looks like:
Code: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:hashtable="clitype:System.Collections.Hashtable">
<xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:variable name="languageCode" select="'lang'" /> <xsl:template match="/"> <xsl:for-each select="nodes/node"> <xsl:apply-templates select="."></xsl:apply-templates> </xsl:for-each> </xsl:template>
<xsl:template match="node"> <xsl:variable name="x" select="'a'" />
<xsl:variable name="itemAttributes" select="hashtable:new()"/> <xsl:value-of select="hashtable:Add( $itemAttributes, 'id', $x )" /> <xsl:value-of select="hashtable:get_Item($itemAttributes, 'id')" /> <!-- need the following line to get to errors --> <xsl:value-of select="hashtable:Clear($itemAttributes)" /> </xsl:template>
</xsl:stylesheet>
My Xml looks like:
Code: <?xml version="1.0" encoding="utf-8" ?> <nodes> <node id="id"></node> <node id="id"></node> </nodes>
Cheers, Warnar
|
|
Rank: Advanced Member
Joined: 12/13/2005 Posts: 2,856 Location: Mauritius
|
Hi warstar,
what do you mean by a "clear call"?
|
|
Rank: Newbie
Joined: 8/6/2009 Posts: 4 Location: NL
|
Hi vlad,
What i mean is that looking at the xslt i would expect that every time the "<xsl:template match="node">" is run a new instance of the hashtable would be created. It seems that i only creates the instance once and that is why every time after finishing the template i need to Clear the hashtable.
This seems illogical to me or do you know if this is excepted behaviour?
(it also seems if i use a "<xsl:element use-attribute-sets" in some cases the information within the "<xsl:attribute-set" get's chached maybe this is the same problem)
|
|
Rank: Advanced Member
Joined: 12/13/2005 Posts: 2,856 Location: Mauritius
|
This one seems to be a bug. You workaround is probably the most appropriate one.
|
|
|
guest |