Xslt extension objects - getting context
I have been using XsltArgumentList.AddExtensionObject
with success. The problem is that when I call functions from xslt, they only receive the arguments that I pass. How can I get the context (what node is being processed).
I am using XslTransform.Transform (myXPathDoc, xslArgs, myWriter);
to start converting.
I've heard of SetContext
and RegisterCustomFunction
, but they only work on objects XPathExpression
...
thanks
a source to share
There is no documented way for an extension function to implicitly access the context of a node .
Pass it as a parameter .
For instance:
<xsl:value-of select="extFn:MyExtensionFunction(.,'A',./code,./date)"/>
You will need to change the code of the extension function: add a new parameter, which must be first in order, and through this new parameter, the extension function gets the current node.
a source to share