且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在XSLT中将文本文件插入到View Html中

更新时间:2023-11-14 23:35:28

目前尚不清楚您想要实现的目标。您的文件不包含任何XML标记,因此您无法使用文档功能加载它。为什么你希望或期望能够在非结构化文本上使用像EmployeeInfo / Employeee这样的XPath,我根本不理解。
如果你想用XSLT使用/加载文本文件那么你可以这样做在XSLT 2.0中使用未解析文本功能。遗憾的是,Microsoft没有XSLT 2.0实现,因此您必须使用第三方工具,如 Saxon 或类似 AltovaXML
如果您在浏览器中使用XSLT,那么您只能使用XSLT 1.0,并且只能使用扩展函数或扩展对象来加载文本文件那么取决于您分别使用浏览器使用的XSLT处理器的浏览器。 IE使用MSXML,如果您需要帮助,请在 MSXML论坛中询问。
如果在.NET框架中使用XslCompiledTransform,那么您还可以使用扩展函数或扩展对象。如果您需要帮助,请告诉我们,我认为***在XSLT样式表之外解析您的文本,并构建一个XmlDocument,您可以将其作为参数传递给样式表,以便能够使用XSLT / XPath处理它。结果

Hi

I have critical question,

I have a text file as SampleData.txt

================  text file =======================

Microsoft Visual Studio .NET 2008
Framework 3.5
Smart Client
================ END PART OF TEXT FILE ==========================

i will insert this text file in XSL, using this syntax

<xsl:value-of select="document('C:\SampleData.txt'')/EmployeeInfo/EmployeeRecord" />

but when i try to view in the html browser, text file cannot able to view in brower

i am getting the following error message

==== ERROR MESSAGE ========================
 THE XML Page cannot displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later

The system cannot locate the resource specified
=========END PART OF ERROR MESSAGE =============================

did any body have come across this problem

please give me the solution

thanks




SYEDHANIF

It is not clear what you want to achieve. Your file does not contain any XML markup so you can't load it with the document function. And why you would want to or expect to be able to use XPath like EmployeeInfo/Employeee on that unstructured text you have I do not understand at all.
If you want to use/load text files with XSLT then you can do that in XSLT 2.0 with the function unparsed-text . Unfortunately Microsoft does not have an XSLT 2.0 implementation so you will have to use third party tools like Saxon or like AltovaXML.
If you use XSLT in the browser then you are restricted to XSLT 1.0 however and loading text files is only possible with extension functions or extension objects where the code then depends on the browser you use respectively the XSLT processor the browser uses. IE uses MSXML, if you need help with that then ask in the MSXML forum.
If you use XslCompiledTransform in the .NET framework then you can also use extension functions or extension objects. Let us know if you need help with that, I think it would be best to parse your text outside of the XSLT stylesheet and build an XmlDocument that you could pass as an argument to the stylesheet to be able to process it with XSLT/XPath.