Hi Sebastian Leupold,
Thanks for your support.
I am not using XML or XSL Module of the Dotnetnuke.
I have created one "XSLTTransformation.aspx" page in Dotnetnuke. In this page, i have write below code to Transform XML file into HTML using XSLT file.
C# Code:
string strGenereatedxml = @"D:\Test.XML";
string strHTML;
string strXSLFIle = @"D:\TestTranform.xslt";
XslCompiledTransform x = new XslCompiledTransform();
XmlDocument docxml = new XmlDocument();
docxml.LoadXml(strGenereatedxml);
System.IO.MemoryStream mStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(strGenereatedxml));
XPathDocument xpathdoc = new XPathDocument(mStream);
XsltSettings xslt_settings = new XsltSettings();
xslt_settings.EnableScript = true;
xslt_settings.EnableDocumentFunction = true;
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(strXSLFile, xslt_settings, new XmlUrlResolver());
MemoryStream ms = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(ms, System.Text.Encoding.ASCII);
StreamReader rd = new StreamReader(ms);
XsltArgumentList argslst = new XsltArgumentList();
argslst.AddParam("strsubFolder", "", strsubFolder);
xslt.Transform(xpathdoc, argslst, writer);
ms.Position = 0;
strHTML = rd.ReadToEnd();
rd.Close();
ms.Close();
XSLT Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
version="1.0">
<xsl:output method="html" indent="no"/>
<xsl:template match="/">
<html>
<img ID="{$matchedfile}" src="{user:GetFileIconURL($matchedfile,$FileExtensionsConfigurationURL)}" width="{$imageWidth}" height="{$imageHeight}" border="0" align="top" ondragstart="fnGetSource();" draggesture="cancelevent();" name="{$strsubFolder}" />
</html>
</xsl:template>
<ms:script language="C#" implements-prefix="user">
<![CDATA[
public string GetFileIconURL(string FileName, string FileExtensionsConfigurationURL)
{
string FileExtension = System.IO.Path.GetExtension(FileName);
XPathDocument xmldoc = new XPathDocument(FileExtensionsConfigurationURL);
XPathNavigator nav = xmldoc.CreateNavigator();
XPathExpression expr;
expr = nav.Compile(@"/FileIcons/FileExtension[@ID='" + FileExtension + "']/@src");
XPathNodeIterator iterator = nav.Select(expr);
iterator.MoveNext();
return iterator.Current.Value;
}
]]>
</ms:script>
</xsl:stylesheet>
NOTE - when i remove C# code from XSLT Code so it works fine otherwise it gives error. It works successfully in 3.5 Framework.
Please help me on this issue.
Regards,
Hitesh Panchal