Project

Profile

Help

Saxon .NET 8.9 Unexpected behaviour

Added by Anonymous over 17 years ago

Legacy ID: #4222632 Legacy Poster: mjp (mperestrello)

I am running Saxon .NET 8.9.0.2 with a transform which uses an namespace mapped to a .NET C# class. <key>xpto:<xsl:value-of select="xchain:GetPersistentProperty($key,'key','norequirement')"/></key> When I run the transform with this statement, everything works as expected. However, if I run this statement in transform: <xsl:variable name="key" select="xchain:SetPersistentProperty($key,'dbconn','Data Source=lb-ixosdev-02;Initial Catalog=xchain','mustnotexist')"/> Then the function is simply ignored (ie not run at all and no error is given.) The transform will continue to the next line without calling the function. The SetPersistentProperty is defined as: static public bool SetPersistentProperty(string propertykey, string propertyname, string propertyvalue, string requirement) Am I missing something ?


Replies (2)

RE: Saxon .NET 8.9 Unexpected behaviour - Added by Anonymous over 17 years ago

Legacy ID: #4222718 Legacy Poster: mjp (mperestrello)

I can now answer the question. The reason is that the variable is only evaluated if/when it is used. Therefore, since in my case it is a dummy, to just get the call done, it is never used and the call is never made. This means you have to use the variable to provoke the execution of the associated function.

RE: Saxon .NET 8.9 Unexpected behaviour - Added by Anonymous over 17 years ago

Legacy ID: #4222760 Legacy Poster: Michael Kay (mhkay)

That's right. Functions with side-effects are always a bit tricky in a functional language. You can usually find a way of tricking Saxon into calling the function by pretending to use the result. As this returns a boolean, one way is to do <xsl:if test="xchain:SetPersistentProperty....> <xsl:sequence select="$empty-sequence"/> </xsl:if> with a global parameter <xsl:param name="empty-sequence" select="()"/> (making it a parameter rather than a variable means Saxon can't work out at compile-time what the value will be.) Michael Kay

    (1-2/2)

    Please register to reply