XML 文件中的本地 XSL 引用
首先是一个简短的任务描述:
有一个 XML 文件引用 *.dll 内的 xsl 样式表。 此 XML 的开头如下所示:
>
此 xml 文件可以在 Internet Explorer 中打开并显示为 HTML,并且只能在 IE 中显示。 (xsl 将 xml 转换为 html)
如您所见,它引用了 win32 系统文件夹,其中保存了 dll 文件。 使用“res://”引用确实有效。
但现在我不想将我的 dll 存储在系统文件夹中,而是在不同的文件夹下,假设%ALLUSERSPROFILE%(环境变量),例如在 Windows XP 上是 C:\Documents and Settings\All用户或 Win7 C:\Users\Public(不确定那个)。
我如何引用该文件夹中的 dll? 是否可以使用环境变量来做到这一点,使其与系统无关? 您会推荐什么解决方案。 (所有 html、xsl 数据都保存在本地计算机上的 dll 中。)
到目前为止,我已尝试将参考行更改为以下内容:
我也尝试过对根文件夹 c: 进行相同的操作,即使没有绝对路径文件(xml 和 dll)位于同一文件夹中。 所有不带 res:// 的尝试都会导致以下错误消息:
系统无法找到指定的资源。 处理资源'file:///C:/Documents and Settings/All Users/name_xsl.dll/...时出错 或“file:///C:/name_xsl.dll/frameset.xsl”
你能帮我吗?为什么找不到该文件? (文件名均为虚构)
First a short task description:
There is an XML file which references a xsl stylesheet which is within a *.dll.
The beginning of this XML looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='res://name_xsl.dll/frameset.xsl'?>
This xml file can be opened and displayed as an HTML within Internet Explorer and only IE.
(The xsl transform the xml to html)
As you can see it references the win32 system folder, in which the dll file is saved.
Referencing with "res://" does work.
But now I do not want to store my dll within the system folder, but under a different folder lets say %ALLUSERSPROFILE% (environment variable) which e.g. on Windows XP is C:\Documents and Settings\All Users or on Win7 C:\Users\Public (Not sure about that one).
How do I reference to the dll lying in that folder?
Is it possible to do this using environment variables, such that it is system independent?
What solution would you recommend.
(All html, xsl data is saved locally within the dll on the local computer.)
So far I have tried to change the reference line to the following:
<?xml-stylesheet type='text/xsl' href='file:///c:/Documents and Settings/All Users/name_xsl.dll/frameset.xsl'?>
I have also tried the same with the root folder c: and even without absolute path having all files (xml and dll) in the same folder.
All attempts without res:// resulted in the following error message:
The system cannot locate the resource specified.
Error processing resource 'file:///C:/Documents and Settings/All Users/name_xsl.dll/...
or 'file:///C:/name_xsl.dll/frameset.xsl'
Could you help me out? Why it does not find the file?
(filenames are fictive)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是解决方案:
注意:
例子:
我针对 file:// 协议测试了这个示例,但它的工作方式应该与 res: 协议相同。在我的系统上,我有一个文本文件位于:
我可以通过放入 Windows 文件资源管理器的导航栏来访问此文件:
注意反斜杠转换为正斜杠,并且无需转义空格。这已经过测试并且有效。 res 协议上的等效项尚未经过测试,但它应该以相同的方式工作,当然,res 协议略有不同,因为它还包含资源索引号。
请参阅 http://msdn.microsoft.com /en-us/library/ie/aa767740(v=vs.85).aspx 了解语法。
This is the solution:
Notes:
Example:
I tested this example for the file:// protocol, but it should work the same way as the res: protocol. On my system, I have a text file located at:
I can access this file, by putting into the nav bar of the Windows File Explorer:
Notice backslashes converted to forward slashes, and no need to escape spaces. This has been tested and it works. The equivalent on the res protocol had not been tested, but it should work the same way, except of course that the res protocol is slightly different in that it also includes a resource index number.
Refer http://msdn.microsoft.com/en-us/library/ie/aa767740(v=vs.85).aspx for syntax.