我的目標是建立一個引擎,採用最新的HL7 CDA 3.0文件,使之與HL7 2.5這是一個完全不同的野獸向後兼容。XML轉換爲純文本格式
的CDA文檔是當與其匹配的XSL文件配對呈現一個HTML文件適合顯示給最終用戶的XML文件。
在HL7 2.5中,我需要得到渲染文本,沒有任何標記,並將其摺疊成文字流(或類似文字),我可以用80個字符行寫出來填充HL7 2.5消息。
到目前爲止,我正在使用XslCompiledTransform轉換使用XSLT和產品所得到的HTML文檔我的XML文檔的方法。
我的下一步是採取文件(或者在此之前一個步驟),並呈現HTML文本。我搜索了一段時間,但無法弄清楚如何實現這一點。我希望能夠簡單地忽略它,或者找不到神奇的搜索條件。任何人都可以提供幫助嗎?
FWIW,我讀過的SO 5個或10等問題,這擁抱或使用正則表達式這個告誡,不要以爲我想這條路走。我需要呈現的文本。
using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
public class TransformXML
{
public static void Main(string[] args)
{
try
{
string sourceDoc = "C:\\CDA_Doc.xml";
string resultDoc = "C:\\Result.html";
string xsltDoc = "C:\\CDA.xsl";
XPathDocument myXPathDocument = new XPathDocument(sourceDoc);
XslCompiledTransform myXslTransform = new XslCompiledTransform();
XmlTextWriter writer = new XmlTextWriter(resultDoc, null);
myXslTransform.Load(xsltDoc);
myXslTransform.Transform(myXPathDocument, null, writer);
writer.Close();
StreamReader stream = new StreamReader (resultDoc);
}
catch (Exception e)
{
Console.WriteLine ("Exception: {0}", e.ToString());
}
}
}