XML文件中的本地XSL引用 [英] Local XSL reference within XML-File

查看:218
本文介绍了XML文件中的本地XSL引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先是一个简短的任务描述:



有一个XML文件引用一个* .dll中的xsl样式表。
这个XML的开头如下:



<?xml version =1.0encoding =UTF-8 ?>
<?xml-stylesheet type ='text / xsl'href ='res://name_xsl.dll/frameset.xsl'?>



这个xml文件可以在IE浏览器中打开和显示为HTML,只有IE。
(xsl将xml转换为html)



正如你所看到的,它引用了 win32系统文件夹,其中dll文件被保存。
使用res://引用可以正常工作。



但是现在我不想将我的dll存储在系统文件夹中,但在不同的文件夹让我们说%ALLUSERSPROFILE%(环境变量),例如在Windows XP上是C:\Documents and Settings\All Users or on Win7 C:\Users\Public(不确定那个)。



我是否参考该文件夹中的dll?
可以使用环境变量这样做,这是系统独立的吗?
你会推荐什么解决方案
(所有html,xsl数据本地保存在本地计算机的dll中。)



到目前为止,我已经尝试将参考行更改为以下内容:



<?xml-stylesheet type ='text / xsl'href ='file:/// c:/ Documents and Settings /所有用户/ name_xsl.dll / frameset.xsl'?>



我也尝试过与根文件夹c:没有绝对路径,所有文件(xml和dll)在同一个文件夹。
没有res://的所有尝试导致以下错误消息



系统找不到指定的资源。
错误处理资源文件:/// C:/ Documents and Settings / All Users / name_xsl.dll / ...
或'file:/// C:/name_xsl.dll/frameset。你可以帮我吗?为什么没有找到该文件?
(文件名是虚构的)

解决方案

这是解决方案:

 <?xml-stylesheet type ='text / xsl'href ='res:// C:%5CDocuments and Settings%5CAll Users%5Cname_xsl.dll / frameset.xsl ?> 

注意:



  1. 文件系统反斜杠可以编码为%5C。

示例:
我测试了该示例的文件://协议,但是它应该像res:protocol一样工作。在我的系统上,我有一个文本文件位于:

  C:\Program Files\CodeGear\Delphi for PHP \2.0\privacy.txt 

我可以访问这个文件,放入导航栏Windows文件资源管理器:

  file:///%ProgramFiles%/ CodeGear / Delphi for PHP / 2.0 / privacy.txt 

注意将反斜杠转换为正斜杠,不需要转义空格。这已经过测试,它的工作原理。 res协议的等价物尚未被测试,但它应该以同样的方式工作,除了res协议有些不同之外,它还包括资源索引号。



请参阅 http:// msdn .microsoft.com / en-us / library / ie / aa767740(v = vs85).aspx 用于语法。


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)

解决方案

This is the solution:

<?xml-stylesheet type='text/xsl' href='res://C:%5CDocuments and Settings%5CAll Users%5Cname_xsl.dll/frameset.xsl'?>

Notes:

  1. You MUST use the res:// protocol to access a resource within a file.
  2. File system backslashes can be encoded as %5C . Possibly forward slashes will work as well.

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:

C:\Program Files\CodeGear\Delphi for PHP\2.0\privacy.txt

I can access this file, by putting into the nav bar of the Windows File Explorer:

file:///%ProgramFiles%/CodeGear/Delphi for PHP/2.0/privacy.txt

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.

这篇关于XML文件中的本地XSL引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆