简体   繁体   中英

How to embed HTML produced by C# code in XSL?

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!

Well if you want to return HTML tag soup not conforming to XML rules then you can only return a string and then use eg <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 eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM