hi here i am generating hex 01 and hex 03 with xslt and using c# on transformation hex 01 was genarating like a space in text document if i see in hexadecimal format i could see
 some junk is generating before the hex 01, note this issue was not replicating for hex 03 it was working good,exactly etx was generating, how could i solve this issue ? any idea please..
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:myScripts="myScripts">
<xsl:output method="text" indent="yes"/>
<msxsl:script implements-prefix="myScripts" language="C#">
public string SOH()
{
return '\u0001'.ToString();
}
</msxsl:script>
<msxsl:script implements-prefix="myScripts" language="C#">
public string ETX()
{
return '\u0003'.ToString();
}
</msxsl:script>
<xsl:template match="/">
<xsl:value-of select="myScripts:SOH()"></xsl:value-of>
<xsl:value-of select="myScripts:ETX()"></xsl:value-of>
</xsl:template>
</xsl:stylesheet>
here is my c# code behind code :
XslCompiledTransform transform = new XslCompiledTransform(true);
transform.Load(strCTD, new XsltSettings() { EnableScript = true }, null); // Loading the given Xslt document
var writerSettigns = transform.OutputSettings.Clone();
writerSettigns.CheckCharacters = false;
string strFileName = strpath + langid + strCSVFILE + strMsgType + strORGMSG + strSeqNum + strNowDate + strHour + strMin + strSec + ".FTS";
try
{
MemoryStream memoryStream = new MemoryStream();
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
xmlWriterSettings.Encoding = new UTF8Encoding(false);
xmlWriterSettings.ConformanceLevel = ConformanceLevel.Document;
xmlWriterSettings.Indent = true;
using (XmlWriter writer = XmlWriter.Create(strFileName, writerSettigns))
{
transform.Transform("sampleCTD.xml", xmlArgsList, writer);
}
string xmlString = Encoding.UTF8.GetString(memoryStream.ToArray());
System.IO.StreamWriter file = new System.IO.StreamWriter(strFileName);
file.WriteLine(xmlString);
file.Close();
}
catch (Exception ex)
{
LogError(1, "Form1", "FileGenerationForCID", ex.Message.ToString(), ex.StackTrace.ToString());
throw ex;
}
i have added some code to to avoid BOM error on starting of the text, even though it was not sorted out kindly please can any one suggest on this to me soon ....