tags:

views:

188

answers:

1

I have XSLT that creates HTML from XML. There are several parts of the resulting HTML that I need to create by external C# method (extension method).

  1. How do I embed this C# method into XSLT (within what xsl nodes? I do know how to use common extension functions inside XSLT)
  2. What should my C# function return? HTML-formatted string? With escaped HTML tags or without?

Thank you very much!

A: 

Well if you want to return HTML tag soup not conforming to XML rules then you can only return a string and then use e.g. <xsl:value-of select="pf:yourFunction()" disable-output-escaping="yes"/>. If you want to build a node-set of nodes or a result tree fragment then check the documentation, it shows the mapping between the XSLT types and the .NET framework types e.g. if you want your function to return an result that XSLT sees as a node-set then use the type XPathNodeIterator as the .NET return type of your extension function.

Martin Honnen