I want to transform my Xml with a Xslt file. Can I access to the Xml that is transforming with Xslt in an embedded code piece using C#.
<![CDATA[
public string GetSomething(string path)
{
// Get the whole Xml that is transforming
// And do something with it
// return result
}
]]>
<xsl:value-of select ="GetSomething(courier:_appointment)"/>
Is it possible?
Thanks in advance,
There is some scripting support inside xslt, via
<msxsl:script>, however: it is probably a better idea to use an extension object. Basically, you write a regular C# object (although you need to mark it as COM-callable, IIRC), and add it viaXsltArgumentList, in particularAddExtensionObject– and in the process associate it with a particular urn. Your xslt then declares an xml namespace-alias for the url (i.e.xmlns:myExtension="blah blah"), and usesmyExtension:someMethod(...)in the code.There is a full example on MSDN.