0

I am new to C#-XSLT, I am trying to pass a List to the XSLT file. Someone help me with the below questions. C#:

var Listresponse= Reference.OracleMethod(Parameter);

                    var settings = new XsltSettings();
                    settings.EnableScript = true;

                    // Create the XslCompiledTransform and load the style sheet.
                    XslCompiledTransform xslTransform = new XslCompiledTransform(true);
                    xslTransform.Load("xslfile.xsl", settings, null);

                    // Create an XmlWriter to write the output.
                    XmlWriter writer = XmlWriter.Create("xmlfile.xml");

                    // Transform the file.
                    xslTransform.Transform(new XPathDocument("output.xml"), argsList, writer);
                    writer.Close();

C# Question 1: How to pass the C#  "Listresponse"(List) to the XSLT file.

XSLT:

XSLT Question 2:  What is the URL which needs to specify on the XSLT file for C# Listresponse?

for instance, I have specified the oracle URL here. I need the same for C#. Please help.

Sample  XSLT file with Oracle Package/SP:

<?xml version="1.0" encoding="UTF-16"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
xmlns:test="http://Microsoft.LobServices.OracleDB/2007/03/DB/Package/Package_Name"
xmlns:test1="http://Microsoft.LobServices.OracleDB/2007/03/DB/Package/Package_Name_StoredProcedure_Name"><xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />

  <xsl:template match="/">
    <xsl:apply-templates select="/test:ProcedureResponse" />
  </xsl:template>
  <xsl:template match="/test:ProcedureResponse">
</xsl:stylesheet>
Shan V
  • 1
  • please specify explicit data type for the `var Listresponse` – Yitzhak Khabinsky Jun 17 '20 at 19:20
  • Thanks for your reply, How to pass the "Listresponse" to XSLT? For instance, the below code shows how to pass a string value to XSLT from C#. My question is How to pass the "List values" from C# to XSLT? XsltArgumentList argsList = new XsltArgumentList(); argsList.AddParam("EmployeeID", "", EmployeeID); – Shan V Jun 17 '20 at 19:30
  • To the best of my knowledge it is impossible to pass a List. You can check this link, to see what data types are passable: https://learn.microsoft.com/en-us/dotnet/api/system.xml.xsl.xsltargumentlist.addparam?view=netcore-3.1#remarks – Yitzhak Khabinsky Jun 17 '20 at 20:25
  • Your xslt does not accept parameters. Therefore, nothing can be passed to it. – Alexander Petrov Jun 17 '20 at 21:06
  • @ShanV, I would suggest to pass to XSLT a comma (or any other separator) separated string. This link shows how to do it: https://stackoverflow.com/questions/584082/xslt-best-way-to-split-and-render-comma-separated-text-as-html – Yitzhak Khabinsky Jun 17 '20 at 21:20

0 Answers0